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

            foreach (CachedBelief belief in repo.GetAllCachedBeliefs())
            {
                protocol.post(belief);
            }
        }
示例#2
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()));
        }