Esempio n. 1
0
 // Use this for initialization
 void Start()
 {
     message             = new CMessage((int)PROTOCOL.MESSAGE);
     packet              = new Packet();
     readyInfo           = new ReadyInfo((int)PROTOCOL.GAME_READY);
     currentScrollPos    = new Vector2();
     client              = GameObject.Find("Network").GetComponent <TestClient>();
     this.input_text     = "";
     this.received_texts = new List <string>();
     e = new SocketAsyncEventArgs();
 }
Esempio n. 2
0
        void Join_OK(string msg)
        {
            ConsoleEx.DebugLog(war.Side.ToString() + " received Join_OK. CLient ID = " + msg, ConsoleEx.YELLOW);

            ///
            /// 默认直接准备,实际上应该由UI控制
            ///
            Utils.Assert(proxyReady == false, "Server IS NOT READY yet !");

            ReadyInfo join = new ReadyInfo()
            {
                ClientID = msg,
            };

            string plainJoin = JSON.Instance.ToJSON(join);

            proxyServer.Ready(plainJoin);
        }
Esempio n. 3
0
        public bool NotReady(ReadyInfo notready)
        {
            bool setOk = false;

            if (notready != null)
            {
                VirtualClient client = null;
                setOk = ClientPool.TryGetValue(notready.ClientID, out client);
                if (setOk)
                {
                    client.curStatus  = client.curStatus.clear(ClientStatus.Ready);
                    ReadyClientCount -= 1;

                    AsyncClient();
                }
            }

            return(setOk);
        }
Esempio n. 4
0
        // Use this for initialization
        void Start()
        {
            IPHostEntry host;
            string      myIP = "";

            host = Dns.GetHostEntry(Dns.GetHostName());
            foreach (IPAddress ip in host.AddressList)
            {
                if (ip.AddressFamily.ToString() == "InterNetwork")
                {
                    myIP = ip.ToString();
                }
            }
            client = new TcpClient();
            client.Connect("203.130.66.30", 9000);
            //client.Connect("221.147.174.147", 9000);

            game_main = GameObject.Find("Chatting").GetComponent <GameMain>();

            recv_E            = new SocketAsyncEventArgs();
            recv_E.Completed += new System.EventHandler <SocketAsyncEventArgs>(recv);
            recv_E.SetBuffer(new byte[512], 0, 512);

            message    = new CMessage();
            readyInfo  = new ReadyInfo((int)PROTOCOL.ROOM_IN);
            playerInfo = new PlayerInfo();

            packet  = new Packet();
            send_E  = new SocketAsyncEventArgs();
            pbuffer = new byte[512];

            client.Client.ReceiveAsync(recv_E);

            id_temp = new byte[4];
            temp    = new byte[4];

            DontDestroyOnLoad(gameObject);
        }
Esempio n. 5
0
        public bool Ready(ReadyInfo ready)
        {
            bool setOk = false;

            if (ready != null)
            {
                VirtualClient client = null;
                setOk = ClientPool.TryGetValue(ready.ClientID, out client);

                if (setOk)
                {
                    if (client.curStatus.anysame(ClientStatus.Ready) == false)
                    {
                        client.curStatus  = client.curStatus.set(ClientStatus.Ready);
                        ReadyClientCount += 1;

                        AsyncClient();
                    }
                }
            }

            return(setOk);
        }
Esempio n. 6
0
        public void NotReady(string info)
        {
            ReadyInfo notReadyInfo = JSON.Instance.ToObject <ReadyInfo>(info);

            processedMsg = new NetMQMessage();

            ///加入监控
            bool found = monitor.NotReady(notReadyInfo);

            if (found)
            {
                processedMsg.Append(WarMsgConsts.NotReadyRep);
            }
            else
            {
                processedMsg.Append(WarMsgConsts.NotReadyRepE);
            }

            if (monitor.validateSyncClient)
            {
                proxyCli.SyncClient(monitor.getSyncMsg);
            }
        }