コード例 #1
0
        public void Initialize(string serverIP, int serverPort)
        {
            if (_initialized)
            {
                JLog.Error("JClientSocketManager initialized aready !", JGame.Log.JLogCategory.Network);
                return;
            }
            JNetworkServerInfo.ServerIP   = serverIP;
            JNetworkServerInfo.ServerPort = serverPort;
            IPAddress  serverAdress = IPAddress.Parse(serverIP);
            IPEndPoint serverEdp    = new IPEndPoint(serverAdress, serverPort);

            JClientSocket.socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            JNetworkInteractiveData.ReceivedData = new JNetworkDataQueue();
            JNetworkInteractiveData.SendData     = new JNetworkDataQueue();

            try
            {
                JClientSocket.socket.Connect(serverEdp);
                JLog.Info("Connect to server success.", JGame.Log.JLogCategory.Network);

                JClientDataSenderThread.Initialize();
                JClientDataReceiverThread.Initialize();
            }
            catch (Exception e) {
                JLog.Error(e.Message, JGame.Log.JLogCategory.Network);
                return;
            }
        }
コード例 #2
0
 public void ShutDown()
 {
     JClientDataSenderThread.ShutDown();
 }