| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | |
| | | #if !UNITY_WEBGL && !H5_VERSION |
| | | #if !UNITY_WEBGL |
| | | using System.Net; |
| | | using System.Net.Sockets; |
| | | using System.Threading; |
| | |
| | | { |
| | | GameNetEncode encoder = new GameNetEncode(); |
| | | |
| | | #if !UNITY_WEBGL && !H5_VERSION |
| | | #if !UNITY_WEBGL |
| | | // TCP Socket 实现(非WebGL平台) |
| | | Socket m_Socket; |
| | | public Socket socket { get { return m_Socket; } } |
| | |
| | | { |
| | | get |
| | | { |
| | | #if !UNITY_WEBGL && !H5_VERSION |
| | | #if !UNITY_WEBGL |
| | | return m_Socket == null ? false : m_Socket.Connected; |
| | | #else |
| | | return webSocket != null && webSocket.State == WebSocketState.Open; |
| | |
| | | this.socketType = type; |
| | | } |
| | | |
| | | #if !UNITY_WEBGL && !H5_VERSION |
| | | #if !UNITY_WEBGL |
| | | // ==================== TCP Socket 实现 ==================== |
| | | |
| | | public void Connect(string _ip, int _port, Action<bool> _onConnected) |
| | |
| | | // WebGL需要在Update中轮询消息 |
| | | public void DispatchMessageQueue() |
| | | { |
| | | // #if !UNITY_EDITOR |
| | | #if UNITY_EDITOR |
| | | webSocket?.DispatchMessageQueue(); |
| | | // #endif |
| | | #endif |
| | | } |
| | | |
| | | #endif |