示例#1
0
        // 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);
        }
示例#2
0
 // Header: 50
 public void CreateGameObject(NetworkObjectData data, Socket socket)
 {
     byte[] byteData = ByteParser.ConvertObjectToBytes(data);
     SendFinal(byteData, 50, 2, data.fromId, 0, socket);
 }
示例#3
0
 // 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);
 }
示例#4
0
 // Header: 51
 public void SendJoinRoom(int id, MasterClient client)
 {
     byte[] data = ByteParser.ConvertASCIIToBytes(id.ToString());
     SendFinal(data, 51, 2, client.ourId, 0, client.clientSocket);
 }
示例#5
0
 // Header: 52
 public void SendCreateRoom(MasterClient client)
 {
     byte[] data = ByteParser.ConvertASCIIToBytes("");
     SendFinal(data, 52, 2, client.ourId, 0, client.clientSocket);
 }
示例#6
0
 // Header: 80
 public void SendToggleReady(MasterClient client)
 {
     byte[] data = ByteParser.ConvertASCIIToBytes("");
     SendFinal(data, 80, 2, client.ourId, 0, client.clientSocket);
 }
示例#7
0
        // Header: 88
        public void SendControllerInput(MasterClient client, ControllerInput controllerInput)
        {
            byte[] data = ByteParser.ConvertInputToData(controllerInput);

            SendFinal(data, 88, 2, client.ourId, 0, client.clientSocket);
        }
示例#8
0
        // 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);
        }