void OnGUI() { if (GUILayout.Button("connect")) { Debug.Log("Request Socket Connect"); //(3)请求socket 链接 NetSocket.CBoard.Instance.connectToServer(IP, port); } if (GUILayout.Button("login")) { Debug.Log("Request Login"); //开始登录 twp.protocol.c2fep.ReqEncryptInfo reqEncryptInfo = new twp.protocol.c2fep.ReqEncryptInfo(); NetSocket.CBoard.Instance.send(reqEncryptInfo.ToBin()); } }
void OnGUI() { if (GUILayout.Button("connect")) { Debug.Log("Request Socket Connect"); //(3)请求socket 链接 NetSocket.CBoard.Instance.connectToServer(IP, port); } if(GUILayout.Button("login")) { Debug.Log("Request Login"); //开始登录 twp.protocol.c2fep.ReqEncryptInfo reqEncryptInfo = new twp.protocol.c2fep.ReqEncryptInfo(); NetSocket.CBoard.Instance.send(reqEncryptInfo.ToBin()); } }
public void Update() { // if (mListener == null) // return; lock (mLock) { if (mNetState == ENetState.ES_Connecting) { mConnectWaitTime += (int)(UnityEngine.Time.deltaTime * 1000.0f); if (mConnectWaitTime > mConnectMaxWaitTime) { mNetState = ENetState.ES_Disconnect; if (mSocket != null) { mSocket.Close(); mSocket = null; } //mListener.OnDisconnect(-1); } } while (mReplyList.Count > 0) { LinkedListNode <Reply> replyNode = mReplyList.First; switch (replyNode.Value.Type) { case EReplyType.RT_Connected: { UnityEngine.Debug.Log("RT_Connected : Socket Connect Succeed"); connected = true; #if false twp.protocol.c2fep.ReqEncryptInfo reqEncryptInfo = new twp.protocol.c2fep.ReqEncryptInfo(); CBoard.Instance.send(reqEncryptInfo.ToBin()); #endif break; } case EReplyType.RT_Disconnect: { UnityEngine.Debug.LogWarning("RT_Disconnect"); break; } case EReplyType.RT_DataReply: { //UnityEngine.Debug.LogWarning("RT_DataReply"); UnityEngine.Debug.Log("===packet header: " + System.BitConverter.ToUInt16(replyNode.Value.Data.ToArray(), 0) + "==="); //处理消息 processStram(new NetSocket.ByteArray(replyNode.Value.Data.ToArray())); break; } default: break; } mReplyList.RemoveFirst(); } if (mNetState == ENetState.ES_Disconnect) { Clear(); } #if USE_MULTIPACK mMutiPacketHelp.Send(); #endif } }
public void Update() { // if (mListener == null) // return; lock(mLock) { if (mNetState == ENetState.ES_Connecting) { mConnectWaitTime += (int)(UnityEngine.Time.deltaTime*1000.0f); if (mConnectWaitTime > mConnectMaxWaitTime) { mNetState = ENetState.ES_Disconnect; if (mSocket != null) { mSocket.Close(); mSocket = null; } //mListener.OnDisconnect(-1); } } while(mReplyList.Count > 0) { LinkedListNode<Reply> replyNode = mReplyList.First; switch (replyNode.Value.Type) { case EReplyType.RT_Connected: { UnityEngine.Debug.Log("RT_Connected : Socket Connect Succeed"); connected = true; #if false twp.protocol.c2fep.ReqEncryptInfo reqEncryptInfo = new twp.protocol.c2fep.ReqEncryptInfo(); CBoard.Instance.send(reqEncryptInfo.ToBin()); #endif break; } case EReplyType.RT_Disconnect: { UnityEngine.Debug.LogWarning("RT_Disconnect"); break; } case EReplyType.RT_DataReply: { //UnityEngine.Debug.LogWarning("RT_DataReply"); UnityEngine.Debug.Log("===packet header: " + System.BitConverter.ToUInt16(replyNode.Value.Data.ToArray(), 0) + "==="); //处理消息 processStram(new NetSocket.ByteArray(replyNode.Value.Data.ToArray())); break; } default:break; } mReplyList.RemoveFirst(); } if (mNetState == ENetState.ES_Disconnect) Clear(); #if USE_MULTIPACK mMutiPacketHelp.Send(); #endif } }