예제 #1
0
 public RPCData(RPCPeer peer, Serializer serializer)
     : this()
 {
     Serializer = serializer;
     Peer       = peer;
     Header     = new RPCDataHeader(Serializer);
 }
예제 #2
0
        public T GetCreateProxy <T>(RPCPeer peer, int implId)
        {
            var      tuple = new Tuple <RPCPeer, int>(peer, implId);
            RPCProxy proxy;

            if (proxies.TryGetValue(tuple, out proxy))
            {
                return((T)(object)proxy);
            }

            var serviceType     = typeof(T);
            var serviceAssembly = serviceType.Assembly;

            var implType  = serviceAssembly.GetType(Helper.GetStubsClassName(serviceType, true));
            var proxyType = implType.GetNestedType("Proxy");

            var proxyId = GetNextStubId();

            var stub = Activator.CreateInstance(proxyType, peer, implId, proxyId);

            proxy = (RPCProxy)stub;

            stubs.Add(proxyId, proxy);
            proxies.Add(tuple, proxy);
            proxy.RPCManager = this;

            return((T)stub);
        }
예제 #3
0
파일: RPCData.cs 프로젝트: chartly/flood
 public RPCData(RPCPeer peer, RPCManager rpcManager, Serializer serializer)
 {
     Serializer = serializer;
     Peer = peer;
     RPCManager = rpcManager;
     Header = new RPCDataHeader(Serializer);
     Flags = RPCFlags.None;
 }
예제 #4
0
            internal Call(int id, int methodId, RPCPeer peer, int localId, int remoteId)
            {
                Id       = id;
                MethodId = methodId;
                Data     = RPCData.Create(peer, localId, remoteId, RPCDataType.Call);

                Data.Serializer.WriteI32(id);
                Data.Serializer.WriteI32(methodId);
            }
예제 #5
0
파일: RPCData.cs 프로젝트: chartly/flood
 public RPCData(RPCPeer peer, RPCManager rpcManager, int localId, int remoteId, RPCDataType type, RPCFlags flags = RPCFlags.None)
     : this(peer, rpcManager)
 {
     Flags = flags;
     Header.CallType = type;
     Header.RemoteId = remoteId;
     Header.LocalId = localId;
     Header.Write();
 }
예제 #6
0
        protected RPCProxy(RPCPeer peer, int remoteId, int id)
            : base(id)
        {
            Peer     = peer;
            RemoteId = remoteId;

            callProcessor = new RPCCallProcessor();

            eventIdsDelegates = new Dictionary <int, int>();
        }
예제 #7
0
            internal DelegateCall(int id, int localDelegateId, int remoteDelegateId, RPCPeer peer, int localId, int remoteId)
            {
                Id = id;
                LocalDelegateId  = localDelegateId;
                RemoteDelegateId = remoteDelegateId;
                Data             = RPCData.Create(peer, localId, remoteId, RPCDataType.DelegateCall);

                Data.Serializer.WriteI32(Id);
                Data.Serializer.WriteI32(LocalDelegateId);
                Data.Serializer.WriteI32(RemoteDelegateId);
            }
예제 #8
0
        public static RPCData Create(RPCPeer peer, int localId, int remoteId, RPCDataType type, RPCFlags flags = RPCFlags.None)
        {
            var data = new RPCData(peer);

            data.Peer            = peer;
            data.Flags           = flags;
            data.Header.CallType = type;
            data.Header.RemoteId = remoteId;
            data.Header.LocalId  = localId;
            data.Header.Write();

            return(data);
        }
예제 #9
0
        public void Process(byte[] data, RPCPeer peer)
        {
            var serializer = new BinarySerializer();

            serializer.Buffer.Write(data, 0, data.Length);
            serializer.Buffer.Position = 0;

            var rpcData = new RPCData(peer, serializer);

            rpcData.Header.Read();

            Process(rpcData);
        }
예제 #10
0
        public RPCDelegate CreateDelegateImpl <T>(RPCPeer peer, int remoteId, Delegate del)
            where T : RPCDelegateImpl, new()
        {
            var delegateId   = Interlocked.Increment(ref delegateIdCounter);
            var delegateImpl = Activator.CreateInstance <T>();

            delegateImpl.Id       = delegateId;
            delegateImpl.Delegate = del;
            delegateImpl.Stub     = this;

            delegates.Add(delegateId, delegateImpl);

            return(delegateImpl);
        }
예제 #11
0
        public RPCDelegate CreateDelegateProxy <T>(RPCPeer peer, int remoteId, int remoteDelegateId)
            where T : RPCDelegateProxy, new()
        {
            var delegateId    = Interlocked.Increment(ref delegateIdCounter);
            var delegateProxy = Activator.CreateInstance <T>();

            delegateProxy.Peer             = peer;
            delegateProxy.LocalId          = Id;
            delegateProxy.RemoteId         = remoteId;
            delegateProxy.Id               = delegateId;
            delegateProxy.RemoteDelegateId = remoteDelegateId;
            delegateProxy.Stub             = this;

            delegates.Add(delegateId, delegateProxy);

            return(delegateProxy);
        }
예제 #12
0
파일: RPCData.cs 프로젝트: chartly/flood
            internal DelegateCall(int id, RPCPeer peer, RPCManager rpcManager, int localId, int remoteId)
            {
                Id = id;
                Data = new RPCData(peer, rpcManager, localId, remoteId, RPCDataType.DelegateCall);

                Data.Serializer.WriteI32(id);
            }
예제 #13
0
 public RPCData(RPCPeer peer)
     : this(peer, peer.CreateSerializer())
 {
 }
예제 #14
0
파일: RPCData.cs 프로젝트: chartly/flood
            internal Call(int id, int methodId, RPCPeer peer, RPCManager rpcManager, int localId, int remoteId)
            {
                Id = id;
                MethodId = methodId;
                Data = new RPCData(peer, rpcManager, localId, remoteId, RPCDataType.Call);

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

                if (remoteId == 0)
                {
                    GlobalServiceId = rpcManager.ServiceManager.GetGlobalServiceId(localId);
                    GlobalServiceId.Write(Data);
                }
                else
                {
                    GlobalServiceId = default(GlobalServiceId);
                }
            }
예제 #15
0
 public Subscription(RPCPeer peer, int remoteId)
 {
     Peer = peer;
     RemoteId = remoteId;
 }
예제 #16
0
        public void Subscribe(IObservableDataObject dataObject, RPCPeer 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 RPCData(peer, RPCManager, reference.LocalId, remoteId, RPCDataType.ReferenceSubscribe);
            data.Dispatch();
        }
예제 #17
0
파일: RPCData.cs 프로젝트: chartly/flood
 private RPCData(RPCPeer peer, RPCManager rpcManager)
     : this(peer, rpcManager, peer.CreateSerializer())
 {
 }