- 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
short
current_packet
For status withRemoteConnection.Status.PROCESSING_PACKET
, it is the packet id forsendPacket(short, ByteBuffer)
HandlerList<RemoteConnection>
handlers
SocketChannel
socket
-
构造器概要
构造器 构造器 说明 RemoteConnection(SocketChannel socket)
Create a new connection boxing.
-
方法概要
修饰符和类型 方法 说明 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 methodvoid
sendPacket(short type, @org.jetbrains.annotations.NotNull byte[] data)
Send packet to remotevoid
sendPacket(short type, @org.jetbrains.annotations.NotNull byte[] data, int off, int len)
Send packet to remote.void
sendPacket(short type, @NotNull ByteBuffer send)
Send a packet to remote
-
-
-
字段详细资料
-
socket
public final SocketChannel socket
-
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
-
-
构造器详细资料
-
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 @org.jetbrains.annotations.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 @org.jetbrains.annotations.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
-
sendPacket
public void sendPacket(short type, @NotNull @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
-
-