public void CloseBtn() { SocketEventHandle.getInstance().inviteResponse -= InviteCalback; Destroy(this); Destroy(gameObject); }
public void openGamePlay() { string id = mZhanjiDataItemVo.id + ""; SocketEventHandle.getInstance().gameBackPlayResponse += gameBackPlayResponse; CustomSocket.getInstance().sendMsg(new GameBackPlayRequest(id)); //PrefabManage.loadPerfab ("Prefab/Panel_GamePlayBack"); }
public static SocketEventHandle getInstance() { if (_instance == null) { _instance = (SocketEventHandle)UnityEngine.Object.FindObjectOfType(typeof(SocketEventHandle)); } return(_instance); }
public static SocketEventHandle getInstance() { if (_instance == null) { GameObject temp = new GameObject(); _instance = temp.AddComponent <SocketEventHandle> (); } return(_instance); }
/// <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); } }
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"); } }
void Start() { SocketEventHandle.getInstance(); }
void Start() { SocketEventHandle.getInstance(); //InvokeRepeating("disConnect", 5f, 5f); }
public ServiceErrorListener() { SocketEventHandle.getInstance().serviceErrorNotice += serviceErrorNotice; }
void Start() { SocketEventHandle.getInstance(); now = DateTime.UtcNow; }
// Use this for initialization void Start() { SocketEventHandle.getInstance().inviteResponse += InviteCalback; }
void Start() { isWaiting = false; SocketEventHandle.getInstance(); SocketEventHandle.getInstance().timeWaitResponse = timeWaitCallback; }