C# Class GameCore.NetWork.CNetTCPSocketConnect

Inheritance: INetConnect
Show file Open project: recter/Unity-Net Class Usage Examples

Public Methods

Method Description
CNetTCPSocketConnect ( ) : System

构造函数

Connect ( int nSocketID, string ip, int portnumber, INetworkMsgHandler listener ) : bool

连接开始

DisConnection ( ) : void

关闭连接

GetAllReceivePack ( List packList ) : void

取出消息缓存中所有接收到的消息队列,并清空消息缓存

GetConnectType ( ) : ProtocolType

获取连接类型 tcp or udp or other

GetIP ( ) : string

获取IP

GetPort ( ) : int

获取端口

GetReceivePack ( ) : SocketNetPacket

取出消息缓存中排在最前的一条的消息包的数据,并从消息缓存中移除

GetRectTotalBytes ( ) : uint

接收字节数总数

GetSendTotalBytes ( ) : uint

发送字节数总数

IsConnect ( ) : bool

判断连接是否成功

Reconnect ( ) : bool

断线重连

SendMessage ( int nMessageID, Byte data ) : bool

发送数据

Update ( int &nID ) : ENUM_SOCKET_STATE

连接器更新

Private Methods

Method Description
__Clear ( ) : void

变量初始化

__CreateNetWorkThread ( ) : bool

创建子线程 用于 读取 和 发送数据 本函数只调用一次

__DestoryNetWorkThread ( ) : void

停止子线程

__OnConnectComplete ( object sender, SocketAsyncEventArgs e ) : void

异步创建连接成功回调

__ReadPacketBody ( ) : bool

读取包体数据

__ReadPacketHead ( ) : bool

读取 包头数据

__RectiveThreadFunc ( ) : void

接收子线程回调函数

__SendThreadFunc ( ) : void

发送子线程回调函数

Method Details

CNetTCPSocketConnect() public method

构造函数
public CNetTCPSocketConnect ( ) : System
return System

Connect() public method

连接开始
public Connect ( int nSocketID, string ip, int portnumber, INetworkMsgHandler listener ) : bool
nSocketID int
ip string 服务器IP地址
portnumber int 端口信息
listener INetworkMsgHandler
return bool

DisConnection() public method

关闭连接
public DisConnection ( ) : void
return void

GetAllReceivePack() public method

取出消息缓存中所有接收到的消息队列,并清空消息缓存
public GetAllReceivePack ( List packList ) : void
packList List
return void

GetConnectType() public method

获取连接类型 tcp or udp or other
public GetConnectType ( ) : ProtocolType
return ProtocolType

GetIP() public method

获取IP
public GetIP ( ) : string
return string

GetPort() public method

获取端口
public GetPort ( ) : int
return int

GetReceivePack() public method

取出消息缓存中排在最前的一条的消息包的数据,并从消息缓存中移除
public GetReceivePack ( ) : SocketNetPacket
return SocketNetPacket

GetRectTotalBytes() public method

接收字节数总数
public GetRectTotalBytes ( ) : uint
return uint

GetSendTotalBytes() public method

发送字节数总数
public GetSendTotalBytes ( ) : uint
return uint

IsConnect() public method

判断连接是否成功
public IsConnect ( ) : bool
return bool

Reconnect() public method

断线重连
public Reconnect ( ) : bool
return bool

SendMessage() public method

发送数据
public SendMessage ( int nMessageID, Byte data ) : bool
nMessageID int
data Byte
return bool

Update() public method

连接器更新
public Update ( int &nID ) : ENUM_SOCKET_STATE
nID int
return ENUM_SOCKET_STATE