예제 #1
0
        public void CloseBtn()
        {
            SocketEventHandle.getInstance().inviteResponse -= InviteCalback;

            Destroy(this);
            Destroy(gameObject);
        }
예제 #2
0
        public void  openGamePlay()
        {
            string id = mZhanjiDataItemVo.id + "";

            SocketEventHandle.getInstance().gameBackPlayResponse += gameBackPlayResponse;
            CustomSocket.getInstance().sendMsg(new GameBackPlayRequest(id));
            //PrefabManage.loadPerfab ("Prefab/Panel_GamePlayBack");
        }
예제 #3
0
 public static SocketEventHandle getInstance()
 {
     if (_instance == null)
     {
         _instance = (SocketEventHandle)UnityEngine.Object.FindObjectOfType(typeof(SocketEventHandle));
     }
     return(_instance);
 }
예제 #4
0
 public static SocketEventHandle getInstance()
 {
     if (_instance == null)
     {
         GameObject temp = new GameObject();
         _instance = temp.AddComponent <SocketEventHandle> ();
     }
     return(_instance);
 }
예제 #5
0
        /// <summary>
        /// Receives the call back.
        /// </summary>
        /// <param name="ar">Ar.</param>
        private void ReceiveCallBack(IAsyncResult ar)
        {
            //通知调用端接收完毕
            try
            {
                //int REnd = socket.EndReceive(ar);
                //BinaryReader br = new BinaryReader(m_receiveBuffer);
                MyDebug.Log("socket.Available === >>>  " + socket.Available);
                if (socket.Available <= 0)
                {
                    MemoryStream ms         = new MemoryStream(m_receiveBuffer);
                    BinaryReader buffers    = new BinaryReader(ms, UTF8Encoding.Default);
                    byte         flag       = buffers.ReadByte();
                    int          lens       = ReadInt(buffers.ReadBytes(4));
                    int          headcode   = ReadInt(buffers.ReadBytes(4));
                    int          status     = ReadInt(buffers.ReadBytes(4));
                    short        messageLen = ReadShort(buffers.ReadBytes(2));
                    MyDebug.Log("response.flag = " + flag);
                    socket.EndReceive(ar);
                    if (flag == 1)
                    {
                        string         message  = Encoding.UTF8.GetString(buffers.ReadBytes(messageLen));
                        ClientResponse response = new ClientResponse();
                        response.status   = status;
                        response.message  = message;
                        response.headCode = headcode;
                        MyDebug.Log("response.headCode = " + response.headCode + "  response.message =   " + message);
                        SocketEventHandle.getInstance().addResponse(response);
                    }
                }
                socket.BeginReceive(m_receiveBuffer, 0, m_receiveBuffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallBack), socket);

                //接收下一个消息(因为这是一个递归的调用,所以这样就可以一直接收消息了)
            }
            catch (Exception ex)
            {
                MyDebug.Log("socket exception");
                socket.Close();
                throw new Exception(ex.Message);
            }
        }
예제 #6
0
        private void gameBackPlayResponse(ClientResponse response)
        {
            SocketEventHandle.getInstance().gameBackPlayResponse -= gameBackPlayResponse;

            GlobalDataScript.aa = JsonMapper.ToObject <GamePlayResponseVo> (response.message);
            if (GlobalDataScript.aa.roomvo.gameType == 0)
            {
                PrefabManage.loadPerfab("Prefab/Panel_GamePlayBack");
            }
            else if (GlobalDataScript.aa.roomvo.gameType == 1)
            {
                PrefabManage.loadPerfab("Prefab/Panel_GamePlayBack_pdk");
            }
            else if (GlobalDataScript.aa.roomvo.gameType == 3)
            {
                PrefabManage.loadPerfab("Prefab/Panel_GamePlayBack_DN");
            }
            else if (GlobalDataScript.aa.roomvo.gameType == 4)
            {
                PrefabManage.loadPerfab("Prefab/Panel_GamePlayBack_DZPK");
            }
        }
예제 #7
0
 void Start()
 {
     SocketEventHandle.getInstance();
 }
예제 #8
0
 void Start()
 {
     SocketEventHandle.getInstance();
     //InvokeRepeating("disConnect", 5f, 5f);
 }
예제 #9
0
 public ServiceErrorListener()
 {
     SocketEventHandle.getInstance().serviceErrorNotice += serviceErrorNotice;
 }
예제 #10
0
 void Start()
 {
     SocketEventHandle.getInstance();
     now = DateTime.UtcNow;
 }
예제 #11
0
 // Use this for initialization
 void Start()
 {
     SocketEventHandle.getInstance().inviteResponse += InviteCalback;
 }
예제 #12
0
 void Start()
 {
     isWaiting = false;
     SocketEventHandle.getInstance();
     SocketEventHandle.getInstance().timeWaitResponse = timeWaitCallback;
 }