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

            foreach (CachedBelief belief in repo.GetAllCachedBeliefs())
            {
                protocol.post(belief);
            }
        }
Example #2
0
        public void handleMessage(Message message)
        {
            BSPMessage          bspMessage = parse(message);
            AgentMessageHandler handler    = null;

            if (handlers.TryGetValue(bspMessage.getSourceID(), out handler))
            {
                handler.handleMessage(bspMessage);
            }
        }
Example #3
0
        public void handleMessage(BSPMessage message)
        {
            Belief belief = serializer.generateBelief(message.getData().getBuffer());

            if (belief.getBeliefType() == Belief.BeliefType.WAYPOINT_PATH)
            {
                Log.debug("Received waypoint path");
            }
            repo.Commit(belief);
        }
Example #4
0
        public void handleMessage(BSPMessage message)
        {
            switch (message.getType())
            {
            case BSPMessageType.CONNECT: connectHandler.handleMessage(message);
                break;

            case BSPMessageType.POST: postHandler.handleMessage(message);
                break;

            case BSPMessageType.SYNC: syncHandler.handleMessage(message);
                break;
            }
        }
        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 handleMessage(BSPMessage message)
        {
            RepositoryStateSerializer serializer    = new RepositoryStateSerializer();
            RepositoryState           incomingState = serializer.deserialize(message.getData());

            if (incomingState.RevisionNumber() > remoteState.RevisionNumber())
            {
                this.remoteState = incomingState;
                IEnumerable <CachedBelief> changedBeliefs = repo.Diff(remoteState);
                foreach (CachedBelief belief in changedBeliefs)
                {
                    protocol.post(belief);
                }
            }
        }
        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);
        }
Example #8
0
        private Message formatMessage(BSPMessage data)
        {
            if (data == null)
            {
                Console.Error.WriteLine("Could not format null data");
                return(null);
            }

            int           messageLength = data.getData().size();
            NetworkBuffer messageData   = new NetworkBuffer(HEADER_LENGTH + messageLength);

            messageData.writeInt32(HEADER_TYPE_OFFSET, (int)data.getType());
            messageData.writeInt32(HEADER_SOURCE_OFFSET, data.getSourceID());

            if (data.getData().size() > 0)
            {
                messageData.writeBytes(data.getData().getBuffer(), 0, HEADER_LENGTH, data.getData().size());
            }

            return(new Message(data.getAddress(), messageData.getBuffer()));
        }
        public void handleMessage(BSPMessage message)
        {
            Belief belief = serializer.generateBelief(message.getData().getBuffer());

            repo.Commit(belief);
        }
Example #10
0
            public void send(BSPMessage bspMessage)
            {
                Message message = protocol.formatMessage(bspMessage);

                protocol.messageWriter.write(message);
            }