public void InitUserSock() { if (m_sock != null) { try { if (m_sock.Connected) { m_sock.Disconnect(false); //m_sock.Close(); } } catch (System.Exception ex) { LogSystem.LogError(ex.ToString()); } } m_sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); m_scoket = new UserSock(m_sockcall, m_sock); if (m_gameSender == null) { m_gameSender = new GameSender(); } m_gameSender.SetSocket(ref m_scoket); }
public bool Init(ISockCallee sockcall) { m_lgsockcall = sockcall; m_sockcall = new SockCall(); m_sockcall.SetGameSock(this); if (SysUtil.IsIos) { m_sock = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp); } else { m_sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); } m_scoket = new UserSock(m_sockcall, m_sock); m_gameSender = new GameSender(); m_gameSender.SetSocket(ref m_scoket); m_gameReceiver = new GameReceiver(); m_gameSender.SetReceiver(m_gameReceiver); return(true); }