public void post(CachedBelief belief)
        {
            if (protocol.getConnection().getRemoteAddress() == null)
            {
                return;
            }

            byte[]     bufferData = serializer.serializeBelief(belief.GetBelief());
            BSPMessage message    = new BSPMessage(protocol.getConnection().getRemoteAddress(),
                                                   BSPMessageType.POST,
                                                   protocol.getAgentID(),
                                                   new NetworkBuffer(bufferData));

            protocol.getConnection().send(message);
        }
        public void synchronizeAllBeliefs()
        {
            if (protocol.getConnection().getRemoteAddress() == null)
            {
                return;
            }

            RepositoryStateSerializer serializer = new RepositoryStateSerializer();
            NetworkBuffer             buffer     = serializer.serialize(repo.CurrentState());
            BSPMessage message = new BSPMessage(protocol.getConnection().getRemoteAddress(),
                                                BSPMessageType.SYNC,
                                                protocol.getAgentID(),
                                                buffer);

            protocol.getConnection().send(message);
        }
        public void handleMessage(BSPMessage message)
        {
            protocol.getConnection().setRemoteAddress(message.getAddress());

            foreach (CachedBelief belief in repo.GetAllCachedBeliefs())
            {
                protocol.post(belief);
            }
        }
Example #4
0
        public string getConnectionString(int actorID)
        {
            AgentMessageHandler handler = findHandler(actorID);

            if (handler != null)
            {
                IPEndPoint address = handler.getConnection().getRemoteAddress();
                if (address != null)
                {
                    return(address.ToString());
                }
            }
            return("Not Connected");
        }