gamnit :: RemoteClient :: defaultinit
gamnit :: RemoteClient :: reader
MsgPackDeserializer
used to receive data from this client through socket
gamnit :: RemoteClient :: reader=
MsgPackDeserializer
used to receive data from this client through socket
gamnit :: RemoteClient :: socket=
Communication socket with the clientgamnit :: RemoteClient :: writer
MsgPackSerializer
used to send data to this client through socket
gamnit :: RemoteClient :: writer=
MsgPackSerializer
used to send data to this client through socket
gamnit $ RemoteClient :: SELF
Type of this instance, automatically specialized in every classgamnit $ RemoteClient :: init
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
gamnit :: RemoteClient :: defaultinit
core :: Object :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).gamnit :: RemoteClient :: reader
MsgPackDeserializer
used to receive data from this client through socket
gamnit :: RemoteClient :: reader=
MsgPackDeserializer
used to receive data from this client through socket
gamnit :: RemoteClient :: socket=
Communication socket with the clientgamnit :: RemoteClient :: writer
MsgPackSerializer
used to send data to this client through socket
gamnit :: RemoteClient :: writer=
MsgPackSerializer
used to send data to this client through socket
# Reference to a remote client connected to this server
class RemoteClient
# Communication socket with the client
var socket: TCPStream
# Is this client connected?
fun connected: Bool do return socket.connected
# `MsgPackSerializer` used to send data to this client through `socket`
var writer: MsgPackSerializer is noinit
# `MsgPackDeserializer` used to receive data from this client through `socket`
var reader: MsgPackDeserializer is noinit
init
do
# Setup serialization
writer = new MsgPackSerializer(socket)
writer.cache = new AsyncCache(true)
reader = new MsgPackDeserializer(socket)
writer.link reader
end
# Check for compatibility with the client
fun handshake: Bool
do
print "Server: Handshake initiated by {socket.address}"
# Make sure it is the same app
var server_app = sys.handshake_app_name
var client_app = socket.deserialize_msgpack
if server_app != client_app then
print_error "Server Error: Client app name is '{client_app or else "<invalid>"}'"
# Send an empty string so the client read it and give up
socket.serialize_msgpack ""
socket.close
return false
end
socket.serialize_msgpack server_app
# App version
var app_version = sys.handshake_app_version
var client_version = socket.deserialize_msgpack
if client_version != app_version then
print_error "Handshake Error: client version is different '{client_version or else "<invalid>"}'"
socket.serialize_msgpack ""
socket.close
return false
end
socket.serialize_msgpack app_version
return true
end
end
lib/gamnit/network/server.nit:154,1--211,3