public void Init(uint serviceKey, NetContractDescription description, IMessageFactory messageFactory, INetPeer channel, ActorKey?actor = null)
 {
     Actor           = actor;
     _description    = description;
     _messageFactory = messageFactory;
     Channel         = channel;
 }
        public NetworkPlayerSpawnContext(NetworkEntityGuid guid, INetPeer peer)
        {
            //TODO: Null tests

            NetworkGuid = guid;
            Peer        = peer;
        }
        public NetworkGameObjectPrefabSpawnContext(NetworkEntityGuid guid, GameObjectPrefab prefabId, INetPeer peer)
        {
            //TODO: Check refs

            PrefabId    = prefabId;
            NetworkGuid = guid;
            NetworkPeer = peer;
        }
 public async void OnDisconnectAsync(INetPeer peer)
 {
     Log.Info("disconnected");
     if (_user != null)
     {
         ActorProxy<IUserManager> chatManager = await Node.GetActor<IUserManager>();
         chatManager.Channel.UnregisterUser(_user.Id);
     }
 }
Esempio n. 5
0
        public async void OnDisconnectAsync(INetPeer peer)
        {
            Log.Info("disconnected");
            if (_user != null)
            {
                ActorProxy <IUserManager> chatManager = await Node.GetActor <IUserManager>();

                chatManager.Channel.UnregisterUser(_user.Id);
            }
        }
Esempio n. 6
0
        public NetworkPlayerSpawnContext([NotNull] NetworkEntityGuid guid, [NotNull] INetPeer peer)
        {
            if (guid == null)
            {
                throw new ArgumentNullException(nameof(guid));
            }
            if (peer == null)
            {
                throw new ArgumentNullException(nameof(peer));
            }

            EntityGuid = guid;
            OwnerPeer  = peer;
        }
        void OnPeerDisconnected(INetPeer peer)
        {
            Log.Info("NetId:{0} has disconnected", peer.Channel.Id);
            TNetPeer savedPeer;

            if (PeersByNetId.TryGetValue(peer.Channel.Id, out savedPeer))
            {
                PeersByNetId.Remove(peer.Channel.Id);
                if (!object.ReferenceEquals(savedPeer, peer))
                {
                    throw new Exception("WTF! peer in dictionary is not the same as in disconnect event");
                }
                Log.Info("{0} has disconnected", savedPeer);
                _onNodeDisconnectedSubject.OnNext(savedPeer);
            }
        }
        public NetProxy CreateProxy(uint serviceKey, IMessageFactory messageFactory, INetPeer peer, ActorKey?actorKey = null)
        {
            NetProxy proxy;
            NetContractDescription desc;

            if (_descByTypeId.TryGetValue(serviceKey, out desc))
            {
                proxy = (NetProxy)Activator.CreateInstance(desc.ProxyType);
                proxy.Init(serviceKey, desc, messageFactory, peer, actorKey);
            }
            else
            {
                throw new Exception("Unregistered entity typeId - " + serviceKey);
            }

            return(proxy);
        }
        public ClientSessionServiceContext(INetworkMessageRouterService sendService, INetworkMessageReceiver messageReceiver, INetPeer client)
        {
            if (sendService == null)
            {
                throw new ArgumentNullException(nameof(sendService));
            }
            if (messageReceiver == null)
            {
                throw new ArgumentNullException(nameof(messageReceiver));
            }
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            SendService     = sendService;
            MessageReceiver = messageReceiver;
            ClientNetPeer   = client;
        }
        private void OnUserDisconnected(INetPeer peer)
        {
            ChatRoomClient client;
            if (_usersByChannelId.TryGetValue(peer.Channel.Id, out client))
            {
                client.DisconnectionSubscription.Dispose();
                _usersById.Remove(client.Info.Id);
                _usersByChannelId.Remove(client.Peer.Channel.Id);
                string disconnectMsg = client.Info.Name + " has disconnected";
                _messages.Add(disconnectMsg);

                SendToAll(disconnectMsg);
                Log.Info("User<Name:{0}> has disconnected", client.Info.Name);
                if (!_usersByChannelId.Any())
                {
                    IActorCoordinator coordinator = Node.GetCoordinator<IChatRoom>();

                    coordinator.RemoveActor(Name);//kill me pls
                }
            }
        }
Esempio n. 11
0
        private void OnUserDisconnected(INetPeer peer)
        {
            ChatRoomClient client;

            if (_usersByChannelId.TryGetValue(peer.Channel.Id, out client))
            {
                client.DisconnectionSubscription.Dispose();
                _usersById.Remove(client.Info.Id);
                _usersByChannelId.Remove(client.Peer.Channel.Id);
                string disconnectMsg = client.Info.Name + " has disconnected";
                _messages.Add(disconnectMsg);

                SendToAll(disconnectMsg);
                Log.Info("User<Name:{0}> has disconnected", client.Info.Name);
                if (!_usersByChannelId.Any())
                {
                    IActorCoordinator coordinator = Node.GetCoordinator <IChatRoom>();

                    coordinator.RemoveActor(Name);//kill me pls
                }
            }
        }
		public ClientSessionServiceContext(INetworkMessageRouterService sendService, INetworkMessageReceiver messageReceiver, INetPeer client)
		{
			SendService = sendService;
			MessageReceiver = messageReceiver;
			ClientNetPeer = client;
		}
 public OperationContext(Message message, INetPeer source)
 {
     Message = message;
     Source  = source;
 }
 public ChatRoomClient(INetPeer peer, ChatUserInfo info)
 {
     Peer = peer;
     Info = info;
 }
Esempio n. 15
0
 public ChatRoomClient(INetPeer peer, ChatUserInfo info)
 {
     Peer = peer;
     Info = info;
 }
 public void Init(uint serviceKey, NetContractDescription description, IMessageFactory messageFactory, INetPeer channel, ActorKey? actor = null)
 {
     Actor = actor;
     _description = description;
     _messageFactory = messageFactory;
     Channel = channel;
 }