类 RemoteConnection
- java.lang.Object
-
- cn.mcres.karlatemp.mxlib.event.Event
-
- cn.mcres.karlatemp.mxlib.remote.RemoteConnection
-
- 直接已知子类:
AuthenticationRemoteConnection
public class RemoteConnection extends Event
RemoteConnection. As Server Or Client.The reason we break the specification ourselves is because we want each Remote Server/Connection to have its own listening system instead of the global listening system.
RemoteConnection will not provide static handlers field, as that may lead to the disclosure of security information, which is not what we want.
-
-
嵌套类概要
嵌套类 修饰符和类型 类 说明 static class
RemoteConnection.Status
-
字段概要
字段 修饰符和类型 字段 说明 boolean
acc
protected ByteBuffer
buffer
short
current_packet
For status withRemoteConnection.Status.PROCESSING_PACKET
, it is the packet id forsendPacket(short, ByteBuffer)
HandlerList<RemoteConnection>
handlers
SocketChannel
socket
protected RemoteConnection.Status
status
-
构造器概要
构造器 限定符 构造器 说明 RemoteConnection(SocketChannel socket)
Create a new connection boxing.protected
RemoteConnection(SocketChannel socket, HandlerList handlerList, ByteBuffer buffer)
-
方法概要
修饰符和类型 方法 说明 void
badPacket()
Send "Bad packet" packet and disconnect this connection.void
disconnect()
Close this connectionvoid
disconnect(String message)
Send packet "0x1, <message>" and calldisconnect()
ByteBuffer
getBuffer()
Get the data buffer.HandlerList<RemoteConnection>
getHandlerList()
Get event handlers for this connectionRemoteConnection.Status
getStatus()
Get the current status for this connectionvoid
onSelected()
Execute a Selector select methodprotected void
sendEmptyPacket(short type)
Sending a empty packet.void
sendPacket(short type, byte[] data)
Send packet to remotevoid
sendPacket(short type, byte[] data, int off, int len)
Send packet to remote.void
sendPacket(short type, ByteBuffer send)
Send a packet to remote
-
-
-
字段详细资料
-
socket
public final SocketChannel socket
-
buffer
protected final ByteBuffer buffer
-
acc
public boolean acc
-
current_packet
public short current_packet
For status withRemoteConnection.Status.PROCESSING_PACKET
, it is the packet id forsendPacket(short, ByteBuffer)
-
handlers
public final HandlerList<RemoteConnection> handlers
-
status
protected RemoteConnection.Status status
-
-
构造器详细资料
-
RemoteConnection
protected RemoteConnection(SocketChannel socket, HandlerList handlerList, ByteBuffer buffer)
-
RemoteConnection
public RemoteConnection(SocketChannel socket)
Create a new connection boxing.- 参数:
socket
- The socket channel. Can be ClientSocket or Server Accept Socket.
-
-
方法详细资料
-
getStatus
public RemoteConnection.Status getStatus()
Get the current status for this connection- 返回:
- Current for this connection
-
sendPacket
public void sendPacket(short type, @NotNull byte[] data) throws IOException
Send packet to remote- 参数:
type
- The packet id.data
- The data send- 抛出:
IOException
- IOException
-
getBuffer
public ByteBuffer getBuffer()
Get the data buffer. You need to read the data sent from here.- 返回:
- remote data
-
sendPacket
public void sendPacket(short type, @NotNull byte[] data, int off, int len) throws IOException
Send packet to remote. It usedByteBuffer.wrap(byte[], int, int)
- 参数:
type
- The packet iddata
- The data sendoff
- The data offsetlen
- The data length- 抛出:
IOException
-
sendEmptyPacket
protected void sendEmptyPacket(short type) throws IOException
Sending a empty packet.- 参数:
type
- The packet id.- 抛出:
IOException
- IOException
-
sendPacket
public void sendPacket(short type, @NotNull ByteBuffer send) throws IOException
Send a packet to remote- 参数:
type
- The packet id.send
- The data- 抛出:
IOException
- IOException.
-
badPacket
public void badPacket() throws IOException
Send "Bad packet" packet and disconnect this connection.0x1, "Bad Packet.".getBytes(StandardCharsets.UTF_8)
- 抛出:
IOException
- If cannot send packet/cannot disconnect.
-
disconnect
public void disconnect(String message) throws IOException
Send packet "0x1, <message>" and calldisconnect()
- 参数:
message
- The disconnect message will send.- 抛出:
IOException
- IOException
-
disconnect
public void disconnect() throws IOException
Close this connection- 抛出:
IOException
- when cannot closed this connection.
-
onSelected
public void onSelected() throws IOException
Execute a Selector select method- 抛出:
IOException
- Error- 另请参阅:
Selector
,Selector.select()
,Selector.selectedKeys()
,RemoteServer.select()
-
getHandlerList
public HandlerList<RemoteConnection> getHandlerList()
Get event handlers for this connection- 指定者:
getHandlerList
在类中Event
- 返回:
- The event handlers. NOT GLOBAL
-
-