public void InitSocket() { if( null == socket) return; socket.Close(); socketState = SOCKET_STATE.SS_DISCONNECT; }
public void ConnectToServer( string ip, ushort port, SOCKET_STATE state) { if( ( null != socket) && ( true == socket.Connected)) InitSocket(); socket = new TcpClient(); try { socket.Connect( ip, port); } catch { switch( state) { case SOCKET_STATE.SS_LOGIN: AsNotify.Instance.MessageBox( "Error", "Login server connect\nfailed...!", null, "", AsNotify.MSG_BOX_TYPE.MBT_OK, AsNotify.MSG_BOX_ICON.MBI_ERROR); break; case SOCKET_STATE.SS_GAMESERVER: AsNotify.Instance.MessageBox( "Error", "Game server connect\nfailed...!", null, "", AsNotify.MSG_BOX_TYPE.MBT_OK, AsNotify.MSG_BOX_ICON.MBI_ERROR); break; } } if( true == socket.Connected) { socketState = state; Recv(); } }
public void ConnectToServer( string ip, ushort port, SOCKET_STATE state) { if( ( null != socket) && ( true == socket.Connected)) InitSocket(); socket = new TcpClient(); try { socket.Connect( ip, port); } catch( Exception e) { Debug.Log( "Exception : " + e); switch( state) { case SOCKET_STATE.SS_LOGIN: { AsNotify.Instance.MessageBox( AsTableManager.Instance.GetTbl_String(126), AsTableManager.Instance.GetTbl_String(1446), this, "LoginConnectFailed", AsNotify.MSG_BOX_TYPE.MBT_OK, AsNotify.MSG_BOX_ICON.MBI_ERROR); } return; case SOCKET_STATE.SS_GAMESERVER: { AsNotify.Instance.MessageBox( AsTableManager.Instance.GetTbl_String(126), AsTableManager.Instance.GetTbl_String(1446), this, "GameConnectFailed", AsNotify.MSG_BOX_TYPE.MBT_OK, AsNotify.MSG_BOX_ICON.MBI_ERROR); } return; } throw; } if( true == socket.Connected) { isConnected = socket.Connected; AsCommonSender.isSendLivePack = false; socketState = state; Recv(); } }