예제 #1
0
        /// <summary>
        /// Broast all peers in team, beside self
        /// e.g BroadcastType is Chat
        /// e.g BroadcastType is Region,that will send same region action
        /// </summary>
        /// <param name="peer"></param>
        /// <param name="bundle"></param>
        public void BroadcastEvent(MarsPeer peer, Bundle bundle, BroadcastType broadcastType = BroadcastType.Notice)
        {
            Team            team     = null;
            List <MarsPeer> peerList = new List <MarsPeer>();

            if (Rooms.TryGetValue(peer.team.teamId, out team) == true)
            {
                foreach (MarsPeer for_p in team.peers)
                {
                    if (for_p != peer)
                    {
                        if (broadcastType == BroadcastType.Region)
                        {
                            if (peer.region != for_p.region || peer.region == Constants.SelectRole)
                            {
                                continue;
                            }
                        }
                        peerList.Add(for_p);
                    }
                }
            }
            if (peerList.Count > 0)
            {
                MarsPeer.BroadCastEvent(peerList, bundle);
            }
        }
예제 #2
0
 public override void OnReceive(ToRoomClient session, Stream stream)
 {
     this.BroadcastType = (BroadcastType)ProtocolParser.ReadInt32(stream);
     this.PlayerId      = ProtocolParser.ReadInt32(stream);
     this.MethodName    = ProtocolParser.ReadString(stream);
     this.Args          = (object[])SerializableTypeRegister.Deserialize(stream);
 }
예제 #3
0
        private void Broadcast(BroadcastType type, ICommand command)
        {
            if (!IsMine)
            {
                throw new Exception("只能在自己的玩家中调用RPC");
            }
            bool broadcastToSelfLocally = false;
            bool broadcastToServer      = true;

            if (type == BroadcastType.All)
            {
                broadcastToSelfLocally = true;
            }
            else if (type == BroadcastType.MasterOnly)
            {
                if (IsMaster)
                {
                    broadcastToSelfLocally = true;
                    broadcastToServer      = false;
                }
            }
            if (broadcastToSelfLocally)
            {
                command.OnExecute(this.Session);
            }
            if (broadcastToServer)
            {
                this.Session.Send(command);
            }
        }
예제 #4
0
        protected void SendMessage(Agent senderAgent, Agent currentSenderAgent, Agent receiverAgent,
                                   string receiverId,
                                   BroadcastType messageType,
                                   MessagesContent messageContent, Ruler rulerAgent)
        {
            var message = new Message
            {
                CurrentSenderAgent   = currentSenderAgent,
                CurrentSenderAgentId = currentSenderAgent.AgentId,
                SenderAgentId        = senderAgent.AgentId,
                SenderAgent          = senderAgent,
                ReceiverAgent        = receiverAgent,
                ReceiverAgentId      = receiverId,
                MessageContent       = messageContent,
                MessageType          = messageType
            };

            if (Position.Position.CalculateDistance(message.ReceiverAgent.Position.Position) <= RadioRange)
            {
                message.CurrentReceiverAgent   = message.ReceiverAgent;
                message.CurrentReceiverAgentId = message.ReceiverAgentId;
            }
            else
            {
                var temp = FindNearestMessenger(Position, receiverAgent.Position, message);
                message.RulerPingReply         = rulerAgent;
                message.CurrentReceiverAgent   = temp;
                message.CurrentReceiverAgentId = temp.AgentId;
            }

            Container.ContainerMedia.SendMessage(message.Copy());
        }
예제 #5
0
        /// <summary>
        /// Filters sessions of this group.
        /// </summary>
        /// <param name="from">The current session.</param>
        /// <param name="type">The filtering type.</param>
        /// <value>The array of sessions matching the filter.</value>
        private SessionInfo[] FilterSessions(SessionInfo from, BroadcastType type)
        {
            switch (type)
            {
            case BroadcastType.CurrentSession:
                return(new SessionInfo[] { from });

            case BroadcastType.AllGroup:
                return(_group.Participants.Values.Select(
                           session => session.Session
                           ).ToArray());

            case BroadcastType.AllExceptCurrentSession:
                return(_group.Participants.Values.Select(
                           session => session.Session
                           ).Where(
                           session => !session.Id.Equals(from.Id)
                           ).ToArray());

            case BroadcastType.AllReady:
                return(_group.Participants.Values.Where(
                           session => !session.IsBuffering
                           ).Select(
                           session => session.Session
                           ).ToArray());

            default:
                return(Array.Empty <SessionInfo>());
            }
        }
예제 #6
0
 // Execute all registered callbacks for the input broadcast type
 private void Broadcast(BroadcastType bt)
 {
     foreach (IPausable pausable in pausableDict[bt])
     {
         GetCallback(bt, pausable)();
     }
 }
예제 #7
0
            } // end AddListener  

            public static void RemoveListener(BroadcastType type, Action action) {
                if (!actionMap.ContainsKey(type)) return;
                // end if
                actionMap[type] -= action;
                if (null == actionMap[type]) actionMap.Remove(type);
                // end if
            } // end RemoveListener
예제 #8
0
 public static void AddListener(BroadcastType type, Action action) {
     if (!actionMap.ContainsKey(type)) {
         actionMap[type] = action;
     } else {
         actionMap[type] += action;
     } // end 
 } // end AddListener  
예제 #9
0
 public static void RemoveLisenter(BroadcastType type, Action action)
 {
     if (events.ContainsKey(type))
     {
         events[type] -= action;
     }
 }
예제 #10
0
        private void Broadcast(BroadcastType type)
        {
            List <IClientContract> list = (from item in clientsCollection
                                           where item.Callback != null
                                           select item.Callback as IClientContract).ToList();

            list.ForEach(delegate(IClientContract callback)
            {
                CommunicationState state = ((ICommunicationObject)callback).State;
                if (state == CommunicationState.Opened)
                {
                    try
                    {
                        switch (type)
                        {
                        case BroadcastType.Disconnect:
                            callback.ServerDisconnect();
                            break;

                        case BroadcastType.Ping:
                            callback.Ping();
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
            });
        }
예제 #11
0
        private async Task PostInfo(string url, string serializeObject, BroadcastType broadcastType, BroadcastMessageType broadcastMessageType)
        {
            var context = $"{broadcastType} - {broadcastMessageType}";

            try
            {
                var result = await _httpClient.PostAsync(url, new StringContent(serializeObject, Encoding.UTF8, "application/json"));

                await _log.WriteInfoAsync(ComponentName, context, JsonConvert.SerializeObject(new
                {
                    url,
                    result.StatusCode,
                    reuqest = serializeObject,
                    body    = await result.Content.ReadAsStringAsync()
                }));
            }
            catch (Exception ex)
            {
                await _log.WriteWarningAsync(ComponentName, context, JsonConvert.SerializeObject(new
                {
                    url,
                    reuqest = serializeObject
                }), ex);
            }
        }
예제 #12
0
            } // end RemoveListener

            public static void Broadcast(BroadcastType type) {
                Action action;
                if (actionMap.TryGetValue(type, out action)) {
                    if (null == action) return;
                    // end if
                    action();
                } // end if
            } // end Broadcast
    public void ConditionFilter(Action <BroadcastType> callback)
    {
        BroadcastType _outputType = BroadcastType.None;

        _outputType = NotificationDirectory.ConditionCompare(conditionDatas);

        callback.Invoke(_outputType);
    }
        /// <summary>
        /// Gets the videos from channels the user is following based on the OAuth token provided.
        /// Https://dev.twitch.tv/docs/v5/reference/videos/#get-followed-videos
        /// </summary>
        /// <param name="_pagination">Pagination info <see cref="Helpers.Pagination"/></param>
        /// <param name="_broadcastType">Broadcast type <see cref="Enums.BroadcastType"/></param>
        /// <returns></returns>
        public async Task <dynamic> GetFollowedVideos(Pagination _pagination, BroadcastType _broadcastType = BroadcastType.highlight)
        {
            var request = httpHelperClient.CreateHttpRequest($"kraken/videos/followed", HttpMethod.Get);

            httpHelperClient.AddQueryString(request, _pagination);
            httpHelperClient.AddQueryString(request, "broadcast_type", _broadcastType.ToString());
            return(await httpHelperClient.ExecuteRequest(request));
        }
예제 #15
0
 public void Broadcast(REPeer[] peers, BroadcastType broadcastType, Dictionary<byte, object> parameter)
 {
     EventData eventData = new EventData((byte)broadcastType, parameter);
     foreach (REPeer peer in peers)
     {
         peer.SendEvent(eventData, new SendParameters());
     }
 }
예제 #16
0
 // Register the input pausable object to have its OnPause/OnResume methods called
 public void Register(IPausable pausable)
 {
     // Register the input pausable to be executed for every pausble event
     foreach (BroadcastType bt in BroadcastType.GetValues(typeof(BroadcastType)))
     {
         pausableDict[bt].Add(pausable);
     }
 }
예제 #17
0
        public void Broadcast(DSPeer[] peers, BroadcastType broadcastType, Dictionary <byte, object> parameter)
        {
            EventData eventData = new EventData((byte)broadcastType, parameter);

            foreach (DSPeer peer in peers)
            {
                peer.SendEvent(eventData, new SendParameters());
            }
        }
 public Broadcast(long identifier, string name, BroadcastStatus status, DateTime lastModified, BroadcastType type, BroadcastConfig item)
 {
     id = identifier;
     Name = name;
     Status = status;
     LastModified = lastModified;
     Type = type;
     Item = item;
 }
예제 #19
0
        /// <summary>
        /// Broadcasts a message to the <see cref="Chatroom"/>.
        /// </summary>
        public void BroadcastChatMessage(ConnectionCore connection, BroadcastType broadcastType)
        {
            BroadcastMessageComposer comp = new BroadcastMessageComposer(ID, _LastChatMessageId++, connection.ID, connection.ConnectionData.Username, broadcastType);

            foreach (ConnectionCore user in ChatroomUsers.ToArray())
            {
                user.SendMessage(comp);
            }
        }
예제 #20
0
 public BroadcastInfo(string username, DateTime startTime, TimeSpan duration, BroadcastType type, MediaType mediaType, string label = "")
 {
     Username  = username;
     StartTime = startTime;
     Duration  = duration;
     Type      = type;
     MediaType = mediaType;
     Label     = label;
 }
 public Broadcast(long identifier, string name, BroadcastStatus status, DateTime lastModified, BroadcastType type, BroadcastConfig item)
 {
     id           = identifier;
     Name         = name;
     Status       = status;
     LastModified = lastModified;
     Type         = type;
     Item         = item;
 }
예제 #22
0
 public Triggers(int _triggerType, BroadcastType _broadcastType, List <Events> _events, string _name)
 {
     triggerType     = _triggerType;
     broadcastType   = _broadcastType;
     events          = _events;
     name            = _name;
     probabilities   = new List <float>();
     probabilityLock = new List <bool>();
     afterSeconds    = 0;
 }
        internal static CfBroadcastConfig FromBroadcastConfig(BroadcastConfig source,
                                                              BroadcastType type)
        {
            if (source == null || !DictionaryFromConfig.ContainsKey(type))
            {
                return(null);
            }

            return(DictionaryFromConfig[type].Invoke(source));
        }
예제 #24
0
 public BroadcastInfo(int id, string username, DateTime startTime, TimeSpan duration, BroadcastType type, MediaType mediaType, string filename, string label = "")
 {
     Id        = id;
     Username  = username;
     StartTime = startTime;
     Duration  = duration;
     Type      = type;
     Label     = label;
     Filename  = filename;
 }
        internal static CfBroadcastConfig FromBroadcastConfig(BroadcastConfig source,
        BroadcastType type)
        {
            if (source == null || !DictionaryFromConfig.ContainsKey(type))
            {
                return null;
            }

            return DictionaryFromConfig[type].Invoke(source);
        }
        public BroadcastType GetById(int id)
        {
            BroadcastType result = new BroadcastType();

            using (AppDBContext dbContext = new AppDBContext(_config))
            {
                result = dbContext.BroadcastType.Where(r => r.Id == id).AsNoTracking().SingleOrDefault();
            }
            return(result);
        }
예제 #27
0
        private void GetChatAndSoundFromLists(ref string message, ref string sound, ref BroadcastType type, ref string avatar)
        {
            if (ChatMessages.Count == 0)
            {
                return;
            }

            if (BroadcastRandomly == true)
            {
                var index = Rnd.Next(0, ChatMessages.Count);
                message = ChatMessages[index];

                if (ChatAudio.Count >= ChatMessages.Count)
                {
                    sound = ChatAudio[index];
                }

                if (BroadcastChatType.Count >= ChatMessages.Count)
                {
                    type = BroadcastChatType[index];
                }

                if (ChatAvatar.Count >= ChatMessages.Count)
                {
                    avatar = ChatAvatar[index];
                }
            }
            else
            {
                if (MessageIndex >= ChatMessages.Count)
                {
                    MessageIndex = 0;
                }

                message = ChatMessages[MessageIndex];

                if (ChatAudio.Count >= ChatMessages.Count)
                {
                    sound = ChatAudio[MessageIndex];
                }

                if (BroadcastChatType.Count >= ChatMessages.Count)
                {
                    type = BroadcastChatType[MessageIndex];
                }

                if (ChatAvatar.Count >= ChatMessages.Count)
                {
                    avatar = ChatAvatar[MessageIndex];
                }

                MessageIndex++;
            }
        }
예제 #28
0
        public GetChannelVideosRequest(ulong channelId, BroadcastType type, PageOptions paging)
            : base("GET", $"channels/{channelId}/videos")
        {
            Parameters.Add("limit", paging.Limit);
            Parameters.Add("offset", paging.Offset);

            if (type != BroadcastType.All)
            {
                Parameters.Add("broadcast_type", type.ToString().ToLower());
            }
        }
예제 #29
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mc"></param>
 /// <param name="prio"></param>
 /// <param name="repeat"></param>
 /// <param name="broadcast"></param>
 /// <param name="ack"></param>
 /// <param name="confirm"></param>
 public ControlField1(CemiMessageCode mc, bool extendedFrame = false, Priority prio = Priority.Normal, bool repeat = true, BroadcastType broadcast = BroadcastType.Normal, bool ack = true, ConfirmType confirm = ConfirmType.NoError)
 {
     _messageCode        = mc;
     _extendedFrame      = extendedFrame;
     _repeat             = repeat;
     _broadcast          = broadcast;
     _priority           = prio;
     _acknowledgeRequest = ack;
     _confirm            = confirm;
     ToByte();
 }
    private static BroadcastType BroadcastIntegration(List <NotificationCompareResult> resultGroup)
    {
        BroadcastType _type = resultGroup[0].broadcastType;

        for (int i = 1; i < resultGroup.Count; i++)
        {
            _type |= resultGroup[i].broadcastType;
        }

        return(_type);
    }
예제 #31
0
        internal void Rpc(BroadcastType type, string methodName, params object[] args)
        {
            PlayerRpc command = new PlayerRpc()
            {
                BroadcastType = type,
                MethodName    = methodName,
                PlayerId      = Id,
                Args          = args
            };

            Broadcast(type, command);
        }
예제 #32
0
        internal void ViewRpc(BroadcastType type, int viewId, string methodName, params object[] args)
        {
            ViewRpc command = new ViewRpc()
            {
                BroadcastType = type,
                ViewId        = viewId,
                MethodName    = methodName,
                Args          = args
            };

            Broadcast(type, command);
        }
예제 #33
0
        /// <summary>
        /// Sends a playback command to the interested sessions.
        /// </summary>
        /// <param name="from">The current session.</param>
        /// <param name="type">The filtering type.</param>
        /// <param name="message">The message to send.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <value>The task.</value>
        private Task SendCommand(SessionInfo from, BroadcastType type, SendCommand message, CancellationToken cancellationToken)
        {
            IEnumerable <Task> GetTasks()
            {
                foreach (var session in FilterSessions(from, type))
                {
                    yield return(_sessionManager.SendSyncPlayCommand(session.Id, message, cancellationToken));
                }
            }

            return(Task.WhenAll(GetTasks()));
        }
 internal void BroadcastText(ulong guid, BroadcastType type, string content, int roll_ct)
 {
     UserInfo info = GetUserInfo(guid);
       if (null != info) {
     Msg_BL_BroadcastText builder = new Msg_BL_BroadcastText();
     builder.BroadcastType = (int)type;
     builder.Content = content;
     builder.RollCount = roll_ct;
     LobbyServer.Instance.UserChannel.Send(info.UserSvrName, builder);
       }
 }
 internal void HandleBroadcast(BroadcastType type, string content, int roll_ct)
 {
     if (null == content || content.Length <= 0) {
         return;
     }
 }