@@ -101,43 +101,43 @@ If you don't want to use RPC, override the "message" event on server/client.
1011011. Disabling RPC on GameServer:
102102```gml
103103function GameServer(_port) : TCPServer(_port) constructor {
104- // Disable RPC by setting the message event
105- setEvent("message", function(_message) {
106- var _data = _message.data;
107- var _socket = _message.socket;
108- // If the message type is "create_ball"
109- if (_data.type == "create_ball") {
110- // Store the data
111- data = _data;
112- // Send this data to all clients
113- clients.forEach(function(_client_socket) {
114- network.sendData(data, _client_socket);
115- });
116- }
117- });
104+ // Disable RPC by setting the message event
105+ setEvent("message", function(_message) {
106+ var _data = _message.data;
107+ var _socket = _message.socket;
108+ // If the message type is "create_ball"
109+ if (_data.type == "create_ball") {
110+ // Store the data
111+ data = _data;
112+ // Send this data to all clients
113+ clients.forEach(function(_client_socket) {
114+ network.sendData(data, _client_socket);
115+ });
116+ }
117+ });
118118}
119119```
1201202 . Disable RPC on GameClient:
121121``` gml
122122function GameClient (_ ip, _ port) : TCPSocket(_ ip, _ port) constructor {
123- // Disable RPC by setting the message event
124- setEvent("message", function(_ message) {
125- var _ data = _ message.data;
126- // If the message type is "create_ball"
127- if (_ data.type == "create_ball") {
128- // Create the ball instance
129- instance_create_depth(_ data.x, _ data.y, 0, obj_ball);
130- }
131- });
132- static step = function() {
133- if (mouse_check_button_pressed(mb_left)) {
134- // Send message to create ball
135- network.sendData({
136- type: "create_ball",
137- x: mouse_x,
138- y: mouse_y
139- });
140- }
141- }
123+ // Disable RPC by setting the message event
124+ setEvent("message", function(_ message) {
125+ var _ data = _ message.data;
126+ // If the message type is "create_ball"
127+ if (_ data.type == "create_ball") {
128+ // Create the ball instance
129+ instance_create_depth(_ data.x, _ data.y, 0, obj_ball);
130+ }
131+ });
132+ static step = function() {
133+ if (mouse_check_button_pressed(mb_left)) {
134+ // Send message to create ball
135+ network.sendData({
136+ type: "create_ball",
137+ x: mouse_x,
138+ y: mouse_y
139+ });
140+ }
141+ }
142142}
143143```
0 commit comments