Exemplo n.º 1
0
 public Message(RemotingPeer peer, RemotingManager remotingManager, Serializer serializer)
 {
     Serializer = serializer;
     Peer = peer;
     RemotingManager = remotingManager;
     Header = new DataHeader(Serializer);
     Flags = MessageFlags.None;
 }
Exemplo n.º 2
0
 public Message(RemotingPeer peer, RemotingManager remotingManager, int localId, int remoteId, MessageType type, MessageFlags flags = MessageFlags.None)
     : this(peer, remotingManager)
 {
     Flags = flags;
     Header.CallType = type;
     Header.RemoteId = remoteId;
     Header.LocalId = localId;
     Header.Write();
 }
Exemplo n.º 3
0
        public void Process(byte[] data, RemotingPeer peer)
        {
            var serializer = new BinarySerializer();
            serializer.Buffer.Write(data, 0, data.Length);
            serializer.Buffer.Position = 0;

            var message = new Message(peer, this, serializer);
            message.Header.Read();

            Process(message);
        }
Exemplo n.º 4
0
 public void RequestContext(RemotingPeer peer, Assembly assembly)
 {
     var context = GetCreateContext(assembly);
     var request = new Message(peer, remotingManager, context.LocalId, 0, MessageType.ContextRequest);
     context.ContextId.Write(request);
     request.Dispatch();
 }
Exemplo n.º 5
0
        public Type GetPeerPolymorphicType(RemotingPeer peer, Type type, Type baseType, out ushort remoteContextId, out ushort dataObjectId)
        {
            remoteContextId = 0;
            dataObjectId = 0;

            if (type == null)
                throw new ArgumentNullException("type");

            if (type == baseType)
                return type;

            var dataObjectAttribute = type.GetCustomAttribute<DataObjectAttribute>(false);
            if (dataObjectAttribute != null)
            {
                dataObjectId = dataObjectAttribute.Id;

                var context = GetCreateContext(type.Assembly);

                if (context.RemoteIds != null &&
                    context.RemoteIds.TryGetValue(peer, out remoteContextId))
                    return type;
            }

            return GetPeerPolymorphicType(peer, type.BaseType, baseType, out remoteContextId, out dataObjectId);
        }
Exemplo n.º 6
0
 public Subscription(RemotingPeer peer, int remoteId)
 {
     Peer = peer;
     RemoteId = remoteId;
 }
Exemplo n.º 7
0
        public void Subscribe(IObservableDataObject dataObject, RemotingPeer peer, int remoteId)
        {
            Reference reference;
            if (!dataObjectToReference.TryGetValue(dataObject, out reference))
                reference = CreateReference(dataObject);

            reference.Subscription = new Subscription(peer, remoteId);

            subscriptionToReference.Add(reference.Subscription, reference);

            var data = new Message(peer, remotingManager, reference.LocalId, remoteId, MessageType.ReferenceSubscribe);
            data.Dispatch();
        }
Exemplo n.º 8
0
 private Message(RemotingPeer peer, RemotingManager remotingManager)
     : this(peer, remotingManager, peer.CreateSerializer())
 {
 }
Exemplo n.º 9
0
            internal DelegateCall(int id, RemotingPeer peer, RemotingManager remotingManager, int localId, int remoteId)
            {
                Id = id;
                Data = new Message(peer, remotingManager, localId, remoteId, MessageType.DelegateCall);

                Data.Serializer.WriteI32(id);
            }
Exemplo n.º 10
0
            internal Call(int id, int methodId, RemotingPeer peer, RemotingManager remotingManager, int localId, int remoteId)
            {
                Id = id;
                MethodId = methodId;
                Data = new Message(peer, remotingManager, localId, remoteId, MessageType.Call);

                Data.Serializer.WriteI32(id);
                Data.Serializer.WriteI32(methodId);

                if (remoteId == 0)
                {
                    GlobalServiceId = remotingManager.ServiceManager.GetGlobalServiceId(localId);
                    GlobalServiceId.Write(Data);
                }
                else
                {
                    GlobalServiceId = default(GlobalServiceId);
                }
            }