public void ReceiveBufferTest() { ClientSocketManager target = new ClientSocketManager(); // TODO: 初始化为适当的值 ReceiveQueue actual; actual = target.ReceiveBuffer; Assert.Inconclusive( "验证此测试方法的正确性。" ); }
public void RemoteOnlyIPTest() { ClientSocketManager target = new ClientSocketManager(); // TODO: 初始化为适当的值 string actual; actual = target.RemoteOnlyIP; Assert.Inconclusive( "验证此测试方法的正确性。" ); }
/// <summary> /// 初始化构造 /// </summary> public Connecter() { m_SocketClient.EventProcessData += new EventHandler<ProcessDataAtClientEventArgs>( this.OnConnecterProcessMessageBlock ); m_SocketClient.EventDisconnect += new EventHandler<DisconnectAtClientEventArgs>( this.OnConnecterDisconnect ); m_ClientSocketManager = new ClientSocketManager( this, m_SocketClient.ConnectHandlerManager.ConnectHandler, new ReceiveQueue() ); }
/// <summary> /// 有实例产生时调用 /// </summary> /// <param name="clientSocket"></param> /// <param name="messagePump"></param> internal NetState( ClientSocketManager clientSocket, MessagePump messagePump ) { if ( clientSocket == null ) throw new Exception( "NetState.NetState(...) - clientSocket == null error!" ); if ( messagePump == null ) throw new Exception( "NetState.NetState(...) - messagePump == null error!" ); if ( messagePump.World == null ) throw new Exception( "NetState.NetState(...) - messagePump.World == null error!" ); m_Socket = clientSocket; m_MessagePump = messagePump; m_ConnectedOn = DateTime.Now; m_World = messagePump.World; m_ToString = clientSocket.Address; m_NextCheckActivity = m_ConnectedOn + m_World.CheckAliveTime; IPAddress ipAddress = null; IPAddress.TryParse( clientSocket.RemoteOnlyIP, out ipAddress ); if ( ipAddress == null ) m_NetAddress = new IPEndPoint( IPAddress.None, clientSocket.RemotePort ); else m_NetAddress = new IPEndPoint( ipAddress, clientSocket.RemotePort ); }
public void RemotePortTest() { ClientSocketManager target = new ClientSocketManager(); // TODO: 初始化为适当的值 int actual; actual = target.RemotePort; Assert.Inconclusive( "验证此测试方法的正确性。" ); }
/// <summary> /// 获取新的连接出去的客户端 /// </summary> /// <returns></returns> internal ClientSocketManager Slice() { ClientSocketManager returnSocket = null; m_LockSliceSocket.Enter(); { if (m_IsNeedSlice == true) { m_IsNeedSlice = false; returnSocket = m_ClientSocketManager; } } m_LockSliceSocket.Exit(); return(returnSocket); }
/// <summary> /// 检查是否有新的客户端接出来 /// </summary> private void CheckConnecter() { foreach (Connecter connecter in m_Connecters) { // 检查是否已经处理过 if (connecter.IsNeedSlice == false) { continue; } // 获取连接出去的客户端 ClientSocketManager clientSocketManager = connecter.Slice(); if (clientSocketManager != null) { // 把连接出来的客户端放置入NetState中,当前的实例会保存在NetState.Instances中 NetState netState = new NetState(clientSocketManager, this); this.OnNetStateInit(netState); netState.Start(); } } }
/// <summary> /// 有实例产生时调用 /// </summary> /// <param name="clientSocket"></param> /// <param name="messagePump"></param> internal NetState(ClientSocketManager clientSocket, MessagePump messagePump) { if (clientSocket == null) { throw new Exception("NetState.NetState(...) - clientSocket == null error!"); } if (messagePump == null) { throw new Exception("NetState.NetState(...) - messagePump == null error!"); } if (messagePump.World == null) { throw new Exception("NetState.NetState(...) - messagePump.World == null error!"); } m_Socket = clientSocket; m_MessagePump = messagePump; m_ConnectedOn = DateTime.Now; m_World = messagePump.World; m_ToString = clientSocket.Address; m_NextCheckActivity = m_ConnectedOn + m_World.CheckAliveTime; IPAddress ipAddress = null; IPAddress.TryParse(clientSocket.RemoteOnlyIP, out ipAddress); if (ipAddress == null) { m_NetAddress = new IPEndPoint(IPAddress.None, clientSocket.RemotePort); } else { m_NetAddress = new IPEndPoint(ipAddress, clientSocket.RemotePort); } }
/// <summary> /// 连接新的客户端的处理 /// </summary> /// <param name="NonceClientHandler"></param> /// <param name="AllHandlerManager"></param> /// <param name="ClientHandlerAtServer"></param> private void OnAcceptor(object sender, AcceptorEventArgs eventArgs) { SocketConnectEventArgs socketConnectEventArgs = new SocketConnectEventArgs(eventArgs.AcceptorHandle); GlobalEvent.InvokeSocketConnect(socketConnectEventArgs); // 如果允许连接 if (socketConnectEventArgs.AllowConnection == true) { ClientSocketManager newClientSocketHandler = new ClientSocketManager(this, eventArgs.AcceptorHandle, m_ReceiveQueuePool.AcquirePoolContent()); m_LockAccepted.Enter(); { m_Accepted.Enqueue(newClientSocketHandler); } m_LockAccepted.Exit(); LOGs.WriteLine(LogMessageType.MSG_INFO, LanguageString.SingletonInstance.ListenerString003, eventArgs.AcceptorHandle.ClientAddress, eventArgs.AcceptorHandleManager.OnlineClients, eventArgs.AcceptorHandleManager.TotalClients); // 有新的连接过来需要发送全局信号处理新的连接 m_World.SetWorldSignal(); } else // 不允许连接 { try { eventArgs.AcceptorHandle.CloseSocket(); } catch { Debug.WriteLine("Listener.OnAcceptor(...) - NonceClientHandler.CloseSocket(...) Exception error!"); } LOGs.WriteLine(LogMessageType.MSG_WARNING, LanguageString.SingletonInstance.ListenerString004, eventArgs.AcceptorHandle.ClientAddress, eventArgs.AcceptorHandleManager.OnlineClients, eventArgs.AcceptorHandleManager.TotalClients); } }
public void CloseSocketTest() { ClientSocketManager target = new ClientSocketManager(); // TODO: 初始化为适当的值 target.CloseSocket(); Assert.Inconclusive( "无法验证不返回值的方法。" ); }
public void ListenerSocketTest() { ClientSocketManager target = new ClientSocketManager(); // TODO: 初始化为适当的值 ServiceHandle actual; actual = target.ListenerSocket; Assert.Inconclusive( "验证此测试方法的正确性。" ); }
public void MessageBlockNumbersTest() { ClientSocketManager target = new ClientSocketManager(); // TODO: 初始化为适当的值 long actual; actual = target.MessageBlockNumbers; Assert.Inconclusive( "验证此测试方法的正确性。" ); }
/// <summary> /// 连接新的客户端的处理 /// </summary> /// <param name="NonceClientHandler"></param> /// <param name="AllHandlerManager"></param> /// <param name="ClientHandlerAtServer"></param> private void OnAcceptor( object sender, AcceptorEventArgs eventArgs ) { SocketConnectEventArgs socketConnectEventArgs = new SocketConnectEventArgs( eventArgs.AcceptorHandle ); GlobalEvent.InvokeSocketConnect( socketConnectEventArgs ); // 如果允许连接 if ( socketConnectEventArgs.AllowConnection == true ) { ClientSocketManager newClientSocketHandler = new ClientSocketManager( this, eventArgs.AcceptorHandle, m_ReceiveQueuePool.AcquirePoolContent() ); m_LockAccepted.Enter(); { m_Accepted.Enqueue( newClientSocketHandler ); } m_LockAccepted.Exit(); LOGs.WriteLine( LogMessageType.MSG_INFO, LanguageString.SingletonInstance.ListenerString003, eventArgs.AcceptorHandle.ClientAddress, eventArgs.AcceptorHandleManager.OnlineClients, eventArgs.AcceptorHandleManager.TotalClients ); // 有新的连接过来需要发送全局信号处理新的连接 m_World.SetWorldSignal(); } else // 不允许连接 { try { eventArgs.AcceptorHandle.CloseSocket(); } catch { Debug.WriteLine( "Listener.OnAcceptor(...) - NonceClientHandler.CloseSocket(...) Exception error!" ); } LOGs.WriteLine( LogMessageType.MSG_WARNING, LanguageString.SingletonInstance.ListenerString004, eventArgs.AcceptorHandle.ClientAddress, eventArgs.AcceptorHandleManager.OnlineClients, eventArgs.AcceptorHandleManager.TotalClients ); } }
public void ConnecterTest() { ClientSocketManager target = new ClientSocketManager(); // TODO: 初始化为适当的值 Connecter actual; actual = target.Connecter; Assert.Inconclusive( "验证此测试方法的正确性。" ); }
public void AddressTest() { ClientSocketManager target = new ClientSocketManager(); // TODO: 初始化为适当的值 string actual; actual = target.Address; Assert.Inconclusive( "验证此测试方法的正确性。" ); }
public void OnlineTimeTest() { ClientSocketManager target = new ClientSocketManager(); // TODO: 初始化为适当的值 long actual; actual = target.OnlineTime; Assert.Inconclusive( "验证此测试方法的正确性。" ); }
public void InitClientHandlerTest1() { ClientSocketManager target = new ClientSocketManager(); // TODO: 初始化为适当的值 Listener listener = null; // TODO: 初始化为适当的值 ServiceHandle serviceHandle = null; // TODO: 初始化为适当的值 ReceiveQueue receiveBuffer = null; // TODO: 初始化为适当的值 target.InitClientHandler( listener, serviceHandle, receiveBuffer ); Assert.Inconclusive( "无法验证不返回值的方法。" ); }
public void SendToTest() { ClientSocketManager target = new ClientSocketManager(); // TODO: 初始化为适当的值 MessageBlock sendMessageBlock = MessageBlock.Zero; // TODO: 初始化为适当的值 target.SendTo( sendMessageBlock ); Assert.Inconclusive( "无法验证不返回值的方法。" ); }
public void ClientSocketManagerConstructorTest() { ClientSocketManager target = new ClientSocketManager(); Assert.Inconclusive( "TODO: 实现用来验证目标的代码" ); }
public void NetStateTest() { ClientSocketManager target = new ClientSocketManager(); // TODO: 初始化为适当的值 NetState expected = null; // TODO: 初始化为适当的值 NetState actual; target.NetState = expected; actual = target.NetState; Assert.AreEqual( expected, actual ); Assert.Inconclusive( "验证此测试方法的正确性。" ); }
public void DisconnectSignalTest() { ClientSocketManager target = new ClientSocketManager(); // TODO: 初始化为适当的值 target.DisconnectSignal(); Assert.Inconclusive( "无法验证不返回值的方法。" ); }
public void GetNewSendMessageBlockTest() { ClientSocketManager target = new ClientSocketManager(); // TODO: 初始化为适当的值 MessageBlock expected = MessageBlock.Zero; // TODO: 初始化为适当的值 MessageBlock actual; actual = target.GetNewSendMessageBlock(); Assert.AreEqual( expected, actual ); Assert.Inconclusive( "验证此测试方法的正确性。" ); }
public void InitClientHandlerTest() { ClientSocketManager target = new ClientSocketManager(); // TODO: 初始化为适当的值 Connecter connecter = null; // TODO: 初始化为适当的值 ConnectHandle connectHandle = ConnectHandle.Zero; // TODO: 初始化为适当的值 ReceiveQueue receiveBuffer = null; // TODO: 初始化为适当的值 target.InitClientHandler( connecter, connectHandle, receiveBuffer ); Assert.Inconclusive( "无法验证不返回值的方法。" ); }