Exemple #1
0
    // initializes the speaker with remote voice info
    internal void OnVoiceLinked(int frequency, int channels, int frameSamplesPerChannel, int playDelayMs)
    {
#if !UNITY_EDITOR && UNITY_PS4
        if (frameBuf == null)
        {
            if (framePool == null)
            {
                framePool = new ExitGames.Client.Photon.Voice.PrimitiveArrayPool <float>(FRAME_POOL_CAPACITY, "PhotonVoiceSpeaker");
                framePool.Init(frameSamplesPerChannel * channels);
            }

            int userID = PhotonVoiceSettings.Instance.PS4UserID;
            if (userID == 0)
            {
                UserProfiles.LocalUsers localUsers = new UserProfiles.LocalUsers();
                UserProfiles.GetLocalUsers(localUsers);
                userID = localUsers.LocalUsersIds[0].UserId.Id;
            }
            pPhotonVoiceAudioOutput = egpvopen(userID, GRANULARITY, channels > 1);
            framer = new Framer <float>(GRANULARITY * channels);
            playThreadShouldTerminate = false;
            playThread              = new Thread(Play);
            playThread.Name         = "photon voice audio output thread";
            playThread.IsBackground = true;
            playThread.Start();
            frameBuf = new Dictionary <int, Queue <float[]> >();
        }
        lock (frameBuf)
        {
            frameBuf.Add(GetInstanceID(), new Queue <float[]>());
        }
#endif
        this.player.Start(frequency, channels, frameSamplesPerChannel, playDelayMs);
    }
Exemple #2
0
        public override void Handle(IMessage message)
        {
            var type = message.GetType();

            Log.Trace($"Message {message.MsgId} (Type {type.Name}) to be sent over TCP.");

            if (TcpConnections == null)
            {
                Log.Debug($"TCP connection not yet established - Message {message.MsgId} (Type {type.Name}) will be discarded.");
                return;
            }

            try
            {
                if (TcpConnections.IsEmpty())
                {
                    Log.Error("Cannot send a message without a connection.");
                    return;
                }
                var connection = TcpConnections.First();
                if (!MessageSerializers.TryGetValue(type, out var serializer))
                {
                    serializer = new SimpleJsonSerializer();
                }
                var json   = serializer.SerializeMessage(message);
                var data   = Encoder.ToBytes(json, type);
                var framed = Framer.FrameData(data);
                connection.EnqueueSend(framed);
            }
            catch (Exception ex)
            {
                Log.ErrorException(ex, $"Exception caught while handling Message {message.MsgId} (Type {type.Name})");
            }
        }
        public DefaultRtmpProtocol()
        {
            _framer  = new Framer();
            _chunker = new Chunker();

            _framer.ChunkReceived += (s, e) =>
            {
                _chunker.AddChunk(e.Chunk);
            };

            _chunker.MessageReceived += (s, e) =>
            {
                this.OnMessageReceived(s, e);
            };
        }
        public override void Handle(IMessage message)
        {
            // The server side does not initiate communication. The only messages it will ever send are
            // CommandResponses back to a client who sent a Command.
            var type = message.GetType();

            if (!(message is CommandResponse cmdResponse))
            {
                Log.Debug($"Cannot send a message of type {type.Name} from a server-side TCP bus.");
                return;
            }
            Log.Trace($"Message {message.MsgId} (Type {type.Name}) to be sent over TCP.");

            if (TcpConnections.IsEmpty())
            {
                Log.Debug($"TCP connection not yet established - Message {message.MsgId} (Type {type.Name}) will be discarded.");
                return;
            }

            try
            {
                // Send the CommandResponse back to the endpoint where the Command originated.
                var connectionId = _messageRouting[cmdResponse.SourceCommand.MsgId];
                var connection   = TcpConnections.FirstOrDefault(x => x.ConnectionId == connectionId);
                if (connection is null)
                {
                    throw new Exception("Could not find a TCP connection to use for sending the message.");
                }

                if (!MessageSerializers.TryGetValue(type, out var serializer))
                {
                    serializer = new SimpleJsonSerializer();
                }
                var json   = serializer.SerializeMessage(message);
                var data   = Encoder.ToBytes(json, type);
                var framed = Framer.FrameData(data);
                connection.EnqueueSend(framed);
            }
            catch (Exception ex)
            {
                Log.ErrorException(ex, $"An error occurred while handling Message {message.MsgId} (Type {type.Name})");
            }
        }
        private void ConfigureTcpListener()
        {
            Framer.RegisterMessageArrivedCallback(TcpMessageArrived);
            Action <ITcpConnection, IEnumerable <ArraySegment <byte> > > callback = null;

            callback = (x, data) =>
            {
                try
                {
                    Framer.UnFrameData(data);
                }
                catch (PackageFramingException exc)
                {
                    Log.ErrorException(exc, "LengthPrefixMessageFramer.UnFrameData() threw an exception:");
                    // SendBadRequestAndClose(Guid.Empty, string.Format("Invalid TCP frame received. Error: {0}.", exc.Message));
                    return;
                }
                TcpConnection[0].ReceiveAsync(callback); //client should only have one connection
            };
            TcpConnection[0].ReceiveAsync(callback);     //client should only have one connection
        }
Exemple #6
0
 private StreamStore(EventStoreSettings settings)
 {
     _settings = settings;
     _framer = new Framer(_settings.Serializer);
 }
    public void UnLoad()
    {
        Framer framer = new Framer(unload, 1, false);

        framer.Start();
    }
Exemple #8
0
        // Methods
        private static IEnumerable <string> GetResults(Role role)
        {
            switch (role)
            {
            case Vigilante _:
            case Veteran _:
            case Mafioso _:
            // case Pirate _:
            case Ambusher _:
                return(new[] { Vigilante.GetName(), Veteran.GetName(), Mafioso.GetName(), Ambusher.GetName() });

            case Medium _:
            case Janitor _:
            case Retributionist _:
            // case Necromancer _:
            case Trapper _:
                return(new[] { Medium.GetName(), Janitor.GetName(), Retributionist.GetName(), Trapper.GetName() });

            case Survivor _:
            case VampireHunter _:
            case Amnesiac _:
            // case Medusa _:
            case Psychic _:
                return(new[] { Survivor.GetName(), VampireHunter.GetName(), Amnesiac.GetName(), Psychic.GetName() });

            case Spy _:
            case Blackmailer _:
            case Jailor _:
            case GuardianAngel _:
                return(new[] { Spy.GetName(), Blackmailer.GetName(), Jailor.GetName(), GuardianAngel.GetName() });

            case Sheriff _:
            case Executioner _:
            case Werewolf _:
                // case Poisoner _:
                return(new[] { Sheriff.GetName(), Executioner.GetName(), Werewolf.GetName() });

            case Framer _:
            case Vampire _:
            case Jester _:
                // case HexMaster _:
                return(new[] { Framer.GetName(), Vampire.GetName(), Jester.GetName() });

            case Lookout _:
            case Forger _:
                // case Juggernaut _:
                // case CovenLeader _:
                return(new[] { Lookout.GetName(), Forger.GetName() });

            case Escort _:
            case Transporter _:
            case Consort _:
            case Hypnotist _:
                return(new[] { Escort.GetName(), Transporter.GetName(), Consort.GetName(), Hypnotist.GetName() });

            case Doctor _:
            case Disguiser _:
            case SerialKiller _:
                // case PotionMaster _:
                return(new[] { Doctor.GetName(), Disguiser.GetName(), SerialKiller.GetName() });

            case Investigator _:
            case Consigliere _:
            case Mayor _:
            case Tracker _:
                // case Plaguebearer _:
                return(new[] { Investigator.GetName(), Consigliere.GetName(), Mayor.GetName(), Tracker.GetName() });

            case Bodyguard _:
            case Godfather _:
            case Arsonist _:
            case Crusader _:
                return(new[] { Bodyguard.GetName(), Godfather.GetName(), Arsonist.GetName(), Crusader.GetName() });
            }

            return(new string[] { });
        }
        // Methods
        private static string GetResult(Role role)
        {
            switch (role)
            {
            case Investigator _: return($"{role.Owner.Data.PlayerName} gathers information about people. They must be an {Investigator.GetName()}.");

            case Lookout _: return($"{role.Owner.Data.PlayerName} watches who visits people at night. They must be a {Lookout.GetName()}.");

            case Psychic _: return($"{role.Owner.Data.PlayerName} has the sight. They must be a {Psychic.GetName()}.");

            case Sheriff _: return($"{role.Owner.Data.PlayerName} is a protector of the {Faction.Crew.Name}. They must be a {Sheriff.GetName()}.");

            case Spy _: return($"{role.Owner.Data.PlayerName} secretly watches who someone visits. They must be a {Spy.GetName()}.");

            case Tracker _: return($"{role.Owner.Data.PlayerName} is a skilled in the art of tracking. They must be a {Tracker.GetName()}.");

            case Jailor _:        return($"{role.Owner.Data.PlayerName} detains people at night. They must be a {Jailor.GetName()}.");

            case VampireHunter _: return($"{role.Owner.Data.PlayerName} tracks Vampires. They must be a {VampireHunter.GetName()}!");

            case Veteran _:       return($"{role.Owner.Data.PlayerName} is a paranoid war hero. They must be a {Veteran.GetName()}.");

            case Vigilante _: return($"{role.Owner.Data.PlayerName} will bend the law to enact justice. They must be a {Vigilante.GetName()}.");

            case Bodyguard _: return($"{role.Owner.Data.PlayerName} is a trained protector. They must be a {Bodyguard.GetName()}.");

            case Doctor _:    return($"{role.Owner.Data.PlayerName} is a professional surgeon. They must be a {Doctor.GetName()}.");

            case Crusader _:  return($"{role.Owner.Data.PlayerName} is a divine protector. They must be a {Crusader.GetName()}.");

            case Trapper _:   return($"{role.Owner.Data.PlayerName} is waiting for a big catch. They must be a {Trapper.GetName()}.");

            case Escort _: return($"{role.Owner.Data.PlayerName} is a beautiful person working for the {Faction.Crew.Name}. They must be an {Escort.GetName()}.");

            case Mayor _: return($"{role.Owner.Data.PlayerName} is the leader of the {Faction.Crew.Name}. They must be the {Mayor.GetName()}.");

            case Medium _: return($"{role.Owner.Data.PlayerName} speaks with the dead. They must be a {Medium.GetName()}.");

            case Retributionist _: return($"{role.Owner.Data.PlayerName} wields mystical powers. They must be a {Retributionist.GetName()}.");

            case Transporter _: return($"{role.Owner.Data.PlayerName} specializes in transportation. They must be a {Transporter.GetName()}.");

            case Disguiser _: return($"{role.Owner.Data.PlayerName} makes other people appear to be someone they're not. They must be a {Disguiser.GetName()}");

            case Forger _: return($"{role.Owner.Data.PlayerName} is good at forging documents. They must be a {Forger.GetName()}.");

            case Framer _: return($"{role.Owner.Data.PlayerName} has a desire to deceive. They must be a {Framer.GetName()}!");

            case Hypnotist _: return($"{role.Owner.Data.PlayerName} is skilled at disrupting others. They must be a {Hypnotist.GetName()}.");

            case Janitor _: return($"{role.Owner.Data.PlayerName} cleans up dead bodies. They must be a {Janitor.GetName()}.");

            case Ambusher _: return($"{role.Owner.Data.PlayerName} lies in wait. They must be an {Ambusher.GetName()}.");

            case Godfather _: return($"{role.Owner.Data.PlayerName} is the leader of the {Faction.Mafia.Name}. They must be the {Godfather.GetName()}.");

            case Mafioso _: return($"{role.Owner.Data.PlayerName} does the {Godfather.GetName()}'s dirty work. They must be a {Mafioso.GetName()}.");

            case Blackmailer _: return($"{role.Owner.Data.PlayerName} uses information to silence people. They must be a {Blackmailer.GetName()}.");

            case Consigliere _: return($"{role.Owner.Data.PlayerName} gathers information for the {Faction.Mafia.Name}. They must be a {Consigliere.GetName()}.");

            case Consort _: return($"{role.Owner.Data.PlayerName} is a beautiful person working for the {Faction.Mafia.Name}. They must be a {Consort.GetName()}.");

            case Amnesiac _: return($"{role.Owner.Data.PlayerName} does not remember their role. They must be an {Amnesiac.GetName()}.");

            case GuardianAngel _: return($"{role.Owner.Data.PlayerName} is watching over someone. They must be a {GuardianAngel.GetName()}.");

            case Survivor _: return($"{role.Owner.Data.PlayerName} simply wants to live. They must be a {Survivor.GetName()}.");

            case Vampire _: return($"{role.Owner.Data.PlayerName} drinks blood. They must be a {Vampire.GetName()}!");

            case Executioner _: return($"{role.Owner.Data.PlayerName} wants someone to be lynched at any cost. They must be an {Executioner.GetName()}.");

            case Jester _: return($"{role.Owner.Data.PlayerName} wants to be lynched. They must be a {Jester.GetName()}.");

            case Witch _:  return($"{role.Owner.Data.PlayerName} casts spells on people. They must be a {Witch.GetName()}.");

            case Arsonist _: return($"{role.Owner.Data.PlayerName} likes to watch things burn. They must be an {Arsonist.GetName()}.");

            case SerialKiller _: return($"{role.Owner.Data.PlayerName} wants to kill everyone. They must be a {SerialKiller.GetName()}");

            case Werewolf _: return($"{role.Owner.Data.PlayerName} howls at the moon. They must be a {Werewolf.GetName()}.");

            default: return("No special role found.");
            }
        }