Пример #1
0

"""
	After socket_close, the socket object is not valid any more, so we need to indicate that it should be
	thrown away.
"""


@mbt.action
def socket_close(sockid: "socket"):
    sock = state.sockets[sockid]
    sock.shutdown(socket.SHUT_RDWR)
    sock.close()


mbt.finishedWith(socket_close, "sockid")
"""
	protocol name           valid, invalid
	protocol version        valid, invalid
	clientID	            lengths 0, 1, 22, 23; characters?
	cleansession	        true, false
	will: topic, message, qos, retained
	keepAlive                0, 60,
	username                 None,
	password                 None
"""


@mbt.action
def connect(
    sockid: "socket",
Пример #2
0
	state.clientlist[sockid] = state.clients[state.next_client]
	state.next_client = (state.next_client + 1) % mbt.model.maxobjects["socket"]
	return sockid


"""
	After socket_close, the socket object is not valid any more, so we need to indicate that it should be
	thrown away.
"""
@mbt.action
def socket_close(sockid : "socket"):
	sock = state.sockets[sockid]
	sock.shutdown(socket.SHUT_RDWR)
	sock.close()

mbt.finishedWith(socket_close, "sockid")


"""
	protocol name           valid, invalid
	protocol version        valid, invalid
	clientID	            lengths 0, 1, 22, 23; characters?
	cleansession	        true, false
	will: topic, message, qos, retained
	keepAlive                0, 60,
	username                 None,
	password                 None
"""
@mbt.action
def connect(sockid : "socket", clientid : "clientids", cleansession : "boolean", #willmsg : "willmsgs",
#	    username : "******", password : "******"