// Header: 7 public void SendInfoMessage(Socket sockets, string message, int target) { var data = ByteParser.ConvertObjectToBytes(message); byte headerByte = 7; var sendCodeByte = (byte)target; var newData = new byte[data.Length + 5]; for (var i = 0; i < data.Length; i++) { newData[i + 5] = data[i]; } newData[0] = headerByte; newData[1] = sendCodeByte; var customCodeByte = BitConverter.GetBytes(data.Length); newData[3] = customCodeByte[0]; newData[4] = customCodeByte[1]; sockets.BeginSend(newData, 0, newData.Length, SocketFlags.None, SendCallback, sockets); }
// Header: 50 public void CreateGameObject(NetworkObjectData data, Socket socket) { byte[] byteData = ByteParser.ConvertObjectToBytes(data); SendFinal(byteData, 50, 2, data.fromId, 0, socket); }
// Header: 50 public void SendMasterNetworkPlayer(MasterNetworkPlayer player, int sendCode, int fromCode, int customCode, Socket sockets) { byte[] data = ByteParser.ConvertNetworkPlayerToBytes(player); SendFinal(data, 50, sendCode, fromCode, customCode, sockets); }
// Header: 51 public void SendJoinRoom(int id, MasterClient client) { byte[] data = ByteParser.ConvertASCIIToBytes(id.ToString()); SendFinal(data, 51, 2, client.ourId, 0, client.clientSocket); }
// Header: 52 public void SendCreateRoom(MasterClient client) { byte[] data = ByteParser.ConvertASCIIToBytes(""); SendFinal(data, 52, 2, client.ourId, 0, client.clientSocket); }
// Header: 80 public void SendToggleReady(MasterClient client) { byte[] data = ByteParser.ConvertASCIIToBytes(""); SendFinal(data, 80, 2, client.ourId, 0, client.clientSocket); }
// Header: 88 public void SendControllerInput(MasterClient client, ControllerInput controllerInput) { byte[] data = ByteParser.ConvertInputToData(controllerInput); SendFinal(data, 88, 2, client.ourId, 0, client.clientSocket); }
// Header: 70 public void SendRoom(Room room, int sendCode, Dictionary <Socket, MasterNetworkPlayer> sockets) { var data = ByteParser.ConvertRoomToData(room); SendFinal(data, 70, sendCode, 0, 0, sockets); }