Ejemplo n.º 1
0
        //Sends a 'pong' message to the server
        //TODO this method might be replaced by SendFlagMessage()
        private void ResponsePong()
        {
            if (!isConnected)
            {
                return;
            }

            string     msgJson;
            FlagNetMsg pingFlagMsg;

            Byte[] sendBytes;

            if (bDebug && bVerboseDebug)
            {
                Debug.Log("[Routine] Sending flag to server: pong");
            }

            //Send flag 'ping' to server
            pingFlagMsg = new FlagNetMsg(Flag.PONG);
            msgJson     = JsonUtility.ToJson(pingFlagMsg);
            sendBytes   = Encoding.ASCII.GetBytes(msgJson);
            udp.Send(sendBytes, sendBytes.Length);
        }
Ejemplo n.º 2
0
        private void SendFlagMessage(Flag getFlag)
        {
            if (!isConnected)
            {
                return;
            }

            string     msgJson;
            FlagNetMsg flagMsg;

            Byte[] sendBytes;

            if (bDebug && bVerboseDebug)
            {
                Debug.Log("[Notice] Sending flag " + getFlag.ToString() + " to server...");
            }

            //Send flag to server
            flagMsg   = new FlagNetMsg(getFlag);
            msgJson   = JsonUtility.ToJson(flagMsg);
            sendBytes = Encoding.ASCII.GetBytes(msgJson);
            udp.Send(sendBytes, sendBytes.Length);
        }