public static ResponseParameters DecodeResponse(IClientMessage clientMessage)
        {
            var parameters = new ResponseParameters();
            var status     = clientMessage.GetByte();

            parameters.status = status;
            var addressIsNull = clientMessage.GetBoolean();

            if (!addressIsNull)
            {
                var address = AddressCodec.Decode(clientMessage);
                parameters.address = address;
            }
            var uuidIsNull = clientMessage.GetBoolean();

            if (!uuidIsNull)
            {
                var uuid = clientMessage.GetStringUtf8();
                parameters.uuid = uuid;
            }
            var ownerUuidIsNull = clientMessage.GetBoolean();

            if (!ownerUuidIsNull)
            {
                var ownerUuid = clientMessage.GetStringUtf8();
                parameters.ownerUuid = ownerUuid;
            }
            var serializationVersion = clientMessage.GetByte();

            parameters.serializationVersion = serializationVersion;
            if (clientMessage.IsComplete())
            {
                return(parameters);
            }
            var serverHazelcastVersion = clientMessage.GetStringUtf8();

            parameters.serverHazelcastVersion      = serverHazelcastVersion;
            parameters.serverHazelcastVersionExist = true;
            var clientUnregisteredMembersIsNull = clientMessage.GetBoolean();

            if (!clientUnregisteredMembersIsNull)
            {
                var clientUnregisteredMembers     = new List <Core.IMember>();
                var clientUnregisteredMembersSize = clientMessage.GetInt();
                for (var clientUnregisteredMembersIndex = 0;
                     clientUnregisteredMembersIndex < clientUnregisteredMembersSize;
                     clientUnregisteredMembersIndex++)
                {
                    var clientUnregisteredMembersItem = MemberCodec.Decode(clientMessage);
                    clientUnregisteredMembers.Add(clientUnregisteredMembersItem);
                }
                parameters.clientUnregisteredMembers = clientUnregisteredMembers;
            }
            parameters.clientUnregisteredMembersExist = true;
            return(parameters);
        }
Ejemplo n.º 2
0
            public static void Handle(IClientMessage clientMessage, HandleMember handleMember,
                                      HandleMemberSet handleMemberSet, HandleMemberAttributeChange handleMemberAttributeChange)
            {
                var messageType = clientMessage.GetMessageType();

                if (messageType == EventMessageConst.EventMember)
                {
                    IMember member = null;
                    member = MemberCodec.Decode(clientMessage);
                    int eventType;
                    eventType = clientMessage.GetInt();
                    handleMember(member, eventType);
                    return;
                }
                if (messageType == EventMessageConst.EventMemberSet)
                {
                    IList <IMember> members      = null;
                    var             members_size = clientMessage.GetInt();
                    members = new List <IMember>();
                    for (var members_index = 0; members_index < members_size; members_index++)
                    {
                        IMember members_item;
                        members_item = MemberCodec.Decode(clientMessage);
                        members.Add(members_item);
                    }
                    handleMemberSet(members);
                    return;
                }
                if (messageType == EventMessageConst.EventMemberAttributeChange)
                {
                    string uuid = null;
                    uuid = clientMessage.GetStringUtf8();
                    string key = null;
                    key = clientMessage.GetStringUtf8();
                    int operationType;
                    operationType = clientMessage.GetInt();
                    string value        = null;
                    var    value_isNull = clientMessage.GetBoolean();
                    if (!value_isNull)
                    {
                        value = clientMessage.GetStringUtf8();
                    }
                    handleMemberAttributeChange(uuid, key, operationType, value);
                    return;
                }
                Logger.GetLogger(typeof(AbstractEventHandler))
                .Warning("Unknown message type received on event handler :" + clientMessage.GetMessageType());
            }
Ejemplo n.º 3
0
            internal static void HandleEvent(IClientMessage clientMessage, HandleMemberEventV10 handleMemberEventV10,
                                             HandleMemberListEventV10 handleMemberListEventV10,
                                             HandleMemberAttributeChangeEventV10 handleMemberAttributeChangeEventV10)
            {
                var messageType = clientMessage.GetMessageType();

                if (messageType == EventMessageConst.EventMember)
                {
                    var member    = MemberCodec.Decode(clientMessage);
                    var eventType = clientMessage.GetInt();
                    handleMemberEventV10(member, eventType);
                    return;
                }
                if (messageType == EventMessageConst.EventMemberList)
                {
                    var membersSize = clientMessage.GetInt();
                    var members     = new List <IMember>(membersSize);
                    for (var membersIndex = 0; membersIndex < membersSize; membersIndex++)
                    {
                        var membersItem = MemberCodec.Decode(clientMessage);
                        members.Add(membersItem);
                    }
                    handleMemberListEventV10(members);
                    return;
                }
                if (messageType == EventMessageConst.EventMemberAttributeChange)
                {
                    var    uuid          = clientMessage.GetStringUtf8();
                    var    key           = clientMessage.GetStringUtf8();
                    var    operationType = clientMessage.GetInt();
                    string value         = null;
                    var    valueIsNull   = clientMessage.GetBoolean();
                    if (!valueIsNull)
                    {
                        value = clientMessage.GetStringUtf8();
                    }
                    handleMemberAttributeChangeEventV10(uuid, key, operationType, value);
                    return;
                }
                Logger.GetLogger(typeof(EventHandler)).Warning("Unknown message type received on event handler :" + messageType);
            }
Ejemplo n.º 4
0
            public static void Handle(IClientMessage clientMessage, HandleMember handleMember,
                                      HandleMemberList handleMemberList, HandleMemberAttributeChange handleMemberAttributeChange)
            {
                var messageType = clientMessage.GetMessageType();

                if (messageType == EventMessageConst.EventMember)
                {
                    var member    = MemberCodec.Decode(clientMessage);
                    var eventType = clientMessage.GetInt();
                    handleMember(member, eventType);
                    return;
                }
                if (messageType == EventMessageConst.EventMemberList)
                {
                    var members     = new List <Core.IMember>();
                    var membersSize = clientMessage.GetInt();
                    for (var membersIndex = 0; membersIndex < membersSize; membersIndex++)
                    {
                        var membersItem = MemberCodec.Decode(clientMessage);
                        members.Add(membersItem);
                    }
                    handleMemberList(members);
                    return;
                }
                if (messageType == EventMessageConst.EventMemberAttributeChange)
                {
                    var    uuid          = clientMessage.GetStringUtf8();
                    var    key           = clientMessage.GetStringUtf8();
                    var    operationType = clientMessage.GetInt();
                    string value         = null;
                    var    valueIsNull   = clientMessage.GetBoolean();
                    if (!valueIsNull)
                    {
                        value = clientMessage.GetStringUtf8();
                    }
                    handleMemberAttributeChange(uuid, key, operationType, value);
                    return;
                }
                Hazelcast.Logging.Logger.GetLogger(typeof(AbstractEventHandler))
                .Warning("Unknown message type received on event handler :" + clientMessage.GetMessageType());
            }