Exemple #1
0
    // deserialize join request data
    public bool Deserialize(ref JoinRequestData data)
    {
        // set deserialize data
        bool result = (GetDataSize() > 0) ? true : false;

        // data read failure -> method exit
        if (!result)
        {
            return(false);
        }

        // packet -> multiple string -> seperate stirng
        string linkedString = null;

        result &= Deserialize(ref linkedString, (int)GetDataSize());

        string[] dataSet = linkedString.Split('.');

        // input data
        data.id       = dataSet[0];
        data.password = dataSet[1];

        //return result
        return(result);
    }
Exemple #2
0
 public void Join(int channel_id)
 {
     if (_socket != null)
     {
         var reqData = new JoinRequestData {
             channel_id = channel_id, hidden = false
         };
         var req = new JoinRequest {
             type = "join", data = reqData
         };
         _socket.SendAsync(SerializeJSON <JoinRequest>(req));
     }
 }
Exemple #3
0
    // serialize join request data
    public bool Serialize(JoinRequestData data)
    {
        // clear buffer
        Clear();

        // serialize element
        bool result = true;

        result &= Serialize(data.id);
        result &= Serialize(".");
        result &= Serialize(data.password);

        // failure serialize -> method exit
        if (!result)
        {
            return(false);
        }

        // success serialize -> return result
        return(result);
    }
Exemple #4
0
        // receive section
        // join request
        public void ReceiveJoinRequest(Socket clientSocket, byte[] data)
        {
            // receive packet serialize
            JoinRequestPacket receivePacket   = new JoinRequestPacket(data);
            JoinRequestData   joinRequestData = receivePacket.GetData();

            // process - player join
            bool   result;
            string resultString;

            result = dataProcessor.JoinPlayer(joinRequestData.id, joinRequestData.password, out resultString);

            // make result data
            JoinResultData sendData = new JoinResultData();

            sendData.joinResult = result;
            sendData.message    = resultString;

            // make result packet
            JoinResultPacket sendPacket = new JoinResultPacket(sendData);

            // send result packet
            networkProcessor.Send(clientSocket, sendPacket);
        }