use of me.matoosh.undernet.identity.NetworkIdentity in project UnderNet by itsMatoosh.
the class NeighborNodesManager method onEventCalled.
/**
* Called when the handled event is called.
*
* @param e
*/
@Override
public void onEventCalled(Event e) {
if (e instanceof ChannelCreatedEvent) {
// Sending node info to the connected node.
ChannelCreatedEvent channelCreatedEvent = (ChannelCreatedEvent) e;
sendNodeInfo(Node.self, channelCreatedEvent.remoteNode);
} else if (e instanceof ChannelMessageReceivedEvent) {
ChannelMessageReceivedEvent messageReceivedEvent = (ChannelMessageReceivedEvent) e;
if (messageReceivedEvent.message.msgId == MsgType.NODE_INFO.ordinal()) {
NodeInfoMessage message = (NodeInfoMessage) NetworkMessage.deserializeMessage(messageReceivedEvent.message.data.array());
// TODO: Check the generated id with the database and update.
logger.info("Received node info for " + messageReceivedEvent.remoteNode + ": " + message.networkID);
NetworkIdentity networkIdentity = new NetworkIdentity();
networkIdentity.setNetworkId(message.networkID);
messageReceivedEvent.remoteNode.setIdentity(networkIdentity);
}
}
}
Aggregations