类 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 classRemoteConnection.Status
-
字段概要
字段 修饰符和类型 字段 说明 booleanaccprotected ByteBufferbuffershortcurrent_packetFor status withRemoteConnection.Status.PROCESSING_PACKET, it is the packet id forsendPacket(short, ByteBuffer)HandlerList<RemoteConnection>handlersSocketChannelsocketprotected RemoteConnection.Statusstatus
-
构造器概要
构造器 限定符 构造器 说明 RemoteConnection(SocketChannel socket)Create a new connection boxing.protectedRemoteConnection(SocketChannel socket, HandlerList handlerList, ByteBuffer buffer)
-
方法概要
修饰符和类型 方法 说明 voidbadPacket()Send "Bad packet" packet and disconnect this connection.voiddisconnect()Close this connectionvoiddisconnect(String message)Send packet "0x1, <message>" and calldisconnect()ByteBuffergetBuffer()Get the data buffer.HandlerList<RemoteConnection>getHandlerList()Get event handlers for this connectionRemoteConnection.StatusgetStatus()Get the current status for this connectionvoidonSelected()Execute a Selector select methodprotected voidsendEmptyPacket(short type)Sending a empty packet.voidsendPacket(short type, byte[] data)Send packet to remotevoidsendPacket(short type, byte[] data, int off, int len)Send packet to remote.voidsendPacket(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 IOExceptionSend 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 IOExceptionSend 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 IOExceptionSending a empty packet.- 参数:
type- The packet id.- 抛出:
IOException- IOException
-
sendPacket
public void sendPacket(short type, @NotNull ByteBuffer send) throws IOExceptionSend a packet to remote- 参数:
type- The packet id.send- The data- 抛出:
IOException- IOException.
-
badPacket
public void badPacket() throws IOExceptionSend "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 IOExceptionClose this connection- 抛出:
IOException- when cannot closed this connection.
-
onSelected
public void onSelected() throws IOExceptionExecute 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
-
-