예제 #1
0
        internal override void OnInvokeLocationNetworkly(NetworkIdentity networkIdentity, NetworkInterfaceType networkInterface, string locationName, object locationValue, bool?shouldInvokeSynchronously = null)
        {
            if (!IsConnected)
            {
                throw new Exception("No connection exist!");
            }
            shouldInvokeSynchronously ??= networkInterface == NetworkInterfaceType.TCP;
            SyncVarPacket packet;

            packet = new SyncVarPacket(networkIdentity.Id, locationName, locationValue, shouldInvokeSynchronously.Value);
            Send(packet, networkInterface);
        }
예제 #2
0
 internal static void NetworkSyncVarInvoke(NetworkIdentity identity, SyncVarPacket syncVarPacket, bool shouldInvokeSynchronously)
 {
     if (locationByType.TryGetValue(identity.GetType(), out Dictionary <string, NetworkLocationExecuter> d))
     {
         if (d.TryGetValue(syncVarPacket.LocationName, out NetworkLocationExecuter memberExecuter))
         {
             memberExecuter.InvokeMemberFromNetwork(identity, shouldInvokeSynchronously, syncVarPacket.LocationValue);
             return;
         }
     }
     NetworkBehavior.PrintWarning("No location with name: {0} was not found", syncVarPacket.LocationName);
 }
예제 #3
0
 private protected virtual void ParseSyncVarPacket(SyncVarPacket syncVarPacket, EndPointId endPointId, SocketInfo socketInfo)
 {
     if (TryGetNetworkIdentityByPacket(syncVarPacket, out NetworkIdentity identity))
     {
         NetworkIdentity.NetworkSyncVarInvoke(identity, syncVarPacket, syncVarPacket.ShouldInvokeSynchronously);
     }
     else if (socketInfo.NetworkInterface == NetworkInterfaceType.TCP)
     {
         PrintWarning("cannot get network identity from packet:");
         Print(syncVarPacket.Data.ToArray());
     }
 }
예제 #4
0
        private protected virtual void ParsePacket(PacketId packetId, object[] args, EndPointId endPointId, SocketInfo socketInfo)
        {
            switch (packetId)
            {
            case PacketId.LobbyInfo:
                LobbyInfoPacket lobbyInfoPacket = new LobbyInfoPacket(args.ToList());
                ParseLobbyInfoPacket(lobbyInfoPacket, endPointId, socketInfo);
                break;

            case PacketId.BroadcastMethod:
                BroadcastPacket broadcastPacket = new BroadcastPacket(args.ToList());
                ParseBroadcastPacket(broadcastPacket, broadcastPacket.ShouldInvokeSynchronously, endPointId, socketInfo);
                break;

            case PacketId.Command:
                CommandPacket commandPacket = new CommandPacket(args.ToList());
                ParseCommandPacket(commandPacket, commandPacket.ShouldInvokeSynchronously, endPointId, socketInfo);
                break;

            case PacketId.SyncVar:
                SyncVarPacket syncVarPacket = new SyncVarPacket(args.ToList());
                ParseSyncVarPacket(syncVarPacket, endPointId, socketInfo);
                break;

            case PacketId.SpawnObject:
                SpawnObjectPacket spawnObjectPacket = new SpawnObjectPacket(args.ToList());
                ParseSpawnObjectPacket(spawnObjectPacket, endPointId, socketInfo);
                break;

            case PacketId.SyncObjectVars:
                SyncObjectVars syncObjectVars = new SyncObjectVars(args.ToList());
                ParseSyncObjectVars(syncObjectVars, endPointId, socketInfo);
                break;

            default:
                throw new Exception("Invalid packet recived, id: " + args[0]);
            }
        }
예제 #5
0
 private protected override void ParseSyncVarPacket(SyncVarPacket syncVarPacket, EndPointId endPointId, SocketInfo socketInfo)
 {
     BroadcastPacket(syncVarPacket, endPointId, socketInfo);
     base.ParseSyncVarPacket(syncVarPacket, endPointId, socketInfo);
 }