/// <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); } }
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); }
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); } }
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()); }
/// <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>()); } }
// Execute all registered callbacks for the input broadcast type private void Broadcast(BroadcastType bt) { foreach (IPausable pausable in pausableDict[bt]) { GetCallback(bt, pausable)(); } }
} // 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
public static void AddListener(BroadcastType type, Action action) { if (!actionMap.ContainsKey(type)) { actionMap[type] = action; } else { actionMap[type] += action; } // end } // end AddListener
public static void RemoveLisenter(BroadcastType type, Action action) { if (events.ContainsKey(type)) { events[type] -= action; } }
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); } } }); }
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); } }
} // 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)); }
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()); } }
// 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); } }
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; }
/// <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); } }
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; }
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)); }
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); }
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++; } }
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()); } }
/// <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); }
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); }
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); }
/// <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; } }