예제 #1
0
    public void StreamData(bool spawnSelf, UdpChannelName channel, BoltConnection connection = null)
    {
        StringBuilder sb = new StringBuilder(JsonConvert.SerializeObject(this, Formatting.Indented));

        byte[] aggregationData = Encoding.UTF8.GetBytes(sb.ToString());

        if (connection == null)
        {
            foreach (BoltConnection boltCon in BoltNetwork.Connections)
            {
                boltCon.StreamBytes(channel, aggregationData);
            }
        }
        else
        {
            connection.StreamBytes(channel, aggregationData);
        }

        if (spawnSelf)
        {
            NetworkPartSpawner.Data.AddRange(data);
        }

        data.Clear();
    }
예제 #2
0
 public StreamChannel(UdpChannelName udpChannelName, string name, bool isReliable, int priority, StreamChannelType type)
 {
     UdpChannelName = udpChannelName;
     Name           = name;
     IsReliable     = isReliable;
     Priority       = priority;
     Type           = type;
 }
예제 #3
0
        IStreamChannel FindStreamChannel(UdpChannelName channelName)
        {
            IEqualityComparer <UdpChannelName> equalityComparer = UdpChannelName.EqualityComparer.Instance;

            foreach (var item in _streamChannels)
            {
                if (equalityComparer.Equals(((StreamChannel)item.Value).UdpChannelName, channelName))
                {
                    return(item.Value);
                }
            }
            return(null);
        }
예제 #4
0
    public override void BoltStartBegin()
    {
        InitJsonChannel          = BoltNetwork.CreateStreamChannel(InitJsonChannelName, UdpChannelMode.Reliable, 4);
        WaspJsonChannel          = BoltNetwork.CreateStreamChannel(WaspJsonChannelName, UdpChannelMode.Reliable, 4);
        PlayerJsonChannel        = BoltNetwork.CreateStreamChannel(PlayerJsonChannelName, UdpChannelMode.Reliable, 4);
        StreamAggregationChannel = BoltNetwork.CreateStreamChannel(StreamAggregationName, UdpChannelMode.Reliable, 4);
        UpdateAggregationChannel = BoltNetwork.CreateStreamChannel(UpdateAggregationName, UdpChannelMode.Reliable, 4);


        BoltNetwork.RegisterTokenClass <PartToken>();
        BoltNetwork.RegisterTokenClass <PartTokenParent>();
        BoltNetwork.RegisterTokenClass <PartTokenComplex>();
    }
예제 #5
0
        private void CreateStreamChannels()
        {
            _streamChannels.Clear();

            string[] streamChannelNames  = Enum.GetNames(typeof(StreamChannelType));
            int[]    streamChannelValues = Enum.GetValues(typeof(StreamChannelType)) as int[];

            for (int i = 0; i < streamChannelValues.Length; i++)
            {
                StreamChannelType type = (StreamChannelType)streamChannelValues[i];

                GetStreamChannelSettings(type, out bool reliable, out int priority);

                UdpChannelName photonChannelName = BoltNetwork.CreateStreamChannel(streamChannelNames[i], reliable ? UdpChannelMode.Reliable : UdpChannelMode.Unreliable, priority);

                StreamChannel channel = new StreamChannel(photonChannelName, streamChannelNames[i], reliable, priority, type);

                _streamChannels.Add(type, channel);
            }
        }
예제 #6
0
        public void Event_StreamDataProgress(BoltConnection connection, UdpChannelName channel, ulong streamID, float progress)
        {
            INetworkInterfaceConnection interfaceConnection = FindInterfaceConnection(connection);

            if (interfaceConnection == null)
            {
                Log.Error($"[PhotonNetworkInterface] StreamDataProgress from unknown connection: {connection}.");
                return;
            }

            IStreamChannel streamChannel = FindStreamChannel(channel);

            if (streamChannel == null)
            {
                Log.Error($"[PhotonNetworkInterface] StreamDataProgress from an unknown channel '{channel}'.");
                return;
            }

            StreamDataProgress?.Invoke(interfaceConnection, streamChannel, streamID, progress);
        }
예제 #7
0
        public void Event_StreamDataAborted(BoltConnection connection, UdpChannelName channel, ulong streamID)
        {
            INetworkInterfaceConnection interfaceConnection = FindInterfaceConnection(connection);

            if (interfaceConnection == null)
            {
                Log.Info($"[PhotonNetworkInterface] StreamDataAborted from unknown connection: {connection}.");
            }

            IStreamChannel streamChannel = FindStreamChannel(channel);

            if (streamChannel == null)
            {
                Log.Error($"[PhotonNetworkInterface] StreamDataAborted from an unknown channel '{channel}'.");
                return;
            }

            Log.Info(LogChannel, $"[PhotonNetworkInterface] Incoming stream aborted: (streamID){streamID}");

            StreamDataAborted?.Invoke(interfaceConnection, streamChannel, streamID);
        }
예제 #8
0
    public override void StreamDataProgress(BoltConnection connection, UdpChannelName channel, ulong streamID, float progress)
    {
        if (channel.ToString() == StreamAggregationChannel.ToString())
        {
            return;
        }

        if (channel.ToString() == UpdateAggregationChannel.ToString())
        {
            return;
        }

        if (progressBars == null)
        {
            return;
        }

        if (!progressBars.Active)
        {
            progressBars.ActivateSliders();
        }


        if (channel.ToString() == InitJsonChannel.ToString())
        {
            progressBars.ChangeInitProgress(progress);
        }

        if (channel.ToString() == WaspJsonChannel.ToString())
        {
            progressBars.ChangeWaspProgress(progress);
        }

        if (channel.ToString() == PlayerJsonChannel.ToString())
        {
            progressBars.ChangePlayerProgress(progress);
        }
    }
예제 #9
0
 public override void BoltStartBegin()
 {
     testChannel = BoltNetwork.CreateStreamChannel("test", UdpChannelMode.Reliable, 1);
 }
예제 #10
0
 public override void StreamDataAborted(BoltConnection connection, UdpChannelName channel, ulong streamID)
 {
     BoltLog.Error("Stream {0} on channel {1} from connection {2} has been aborted.", streamID, channel, connection);
 }
예제 #11
0
 public override void StreamDataProgress(BoltConnection connection, UdpChannelName channel, ulong streamID, float progress)
 {
     BoltLog.Info("[{3}%] Connection {0} is transfering data on channel {1} :: Transfer ID {2}", connection, channel, streamID, (int)(progress * 100));
 }
예제 #12
0
    public override void StreamDataStarted(BoltConnection connection, UdpChannelName channel, ulong streamID)
    {
        BoltLog.Warn("Connection {0} is transfering data on channel {1} :: Transfer {2}...", connection, channel, streamID);

        timestamp = Time.time;
    }
예제 #13
0
 public override void StreamDataAborted(BoltConnection connection, UdpChannelName channel, ulong streamID) => PhotonNetworkInterface.Event_StreamDataAborted(connection, channel, streamID);
예제 #14
0
 public override void StreamDataProgress(BoltConnection connection, UdpChannelName channel, ulong streamID, float progress) => PhotonNetworkInterface.Event_StreamDataProgress(connection, channel, streamID, progress);