protected override void SubscribeToEvents(SubscribeEvent e) { eventManager.AddListener <PlayerLandOnStarEvent>(this.OnPlayerLandOnStar); eventManager.AddListener <LoginSuccessfulEvent>(this.OnLoginSuccessful); departButton.onClick.AddListener(() => { this.OnDepart(); }); marketButton.onClick.AddListener(() => { this.OpenMarket(); }); }
public RingEventSnapshootHandler( IAssemblyProvider assemblyProvider , ISnapshootStoreFactory snapshootStoreFactory , IEventRebuildHandler eventRebuildHandler , ISubscribeEventStore subscribeEventStore , ISnapshootCache snapshootCache , ILoggerFactory loggerFactory , IEventHandleSubject eventHandleSubject , int maxHandleCount) : base(maxHandleCount) { this._assemblyProvider = assemblyProvider; _snapshootStoreFactory = snapshootStoreFactory; _eventRebuildHandler = eventRebuildHandler; _subscribeEventStore = subscribeEventStore; _snapshootCache = snapshootCache; _logger = loggerFactory.CreateLogger <RingEventSnapshootHandler>(); _eventHandleSubject = eventHandleSubject; this.Initialize(assemblyProvider.Assemblys); var subscribeEvent = _subscribeEventStore.Get(_defaultSubscribeId); if (subscribeEvent != null) { _subscribeEvent = subscribeEvent; } }
public void Update(SubscribeEvent subscribeEvent) { _subscribeEvent.AggregateRootId = subscribeEvent.AggregateRootId; _subscribeEvent.AggregateRootTypeName = subscribeEvent.AggregateRootTypeName; _subscribeEvent.EventId = subscribeEvent.EventId; _subscribeEvent.UTCTimestamp = subscribeEvent.UTCTimestamp; }
public EventHandleObserver(Guid subscribeId) { this._subscribeEvent = new SubscribeEvent() { Id = subscribeId, UTCTimestamp = 0 }; }
protected override void SubscribeToEvents(SubscribeEvent e) { application.eventManager.AddListener <LoginSuccessfulEvent>(this.OnLoginSuccessful); loginSubmitButton.onClick.AddListener(() => { this.OnSubmit(); }); loginService = application.serviceManager.get <LoginService>() as LoginService; Hide(); }
public void Save(SubscribeEvent subscribeEvent) { _collection.ReplaceOne(a => a.Id == subscribeEvent.Id, subscribeEvent, new UpdateOptions() { IsUpsert = true }); }
public async Task <ActionResult> Subscribe( [FromForm] SubscribeEvent subscribeEvent, CancellationToken cancellationToken) { await _notificationService.AddSubscriber(subscribeEvent?.WebhookUrl, cancellationToken); return(Ok()); }
public void Call() { bool called = false; var se = SubscribeEvent.Create("topic1", () => { called = true; }); se.Call("dummy call topic", new object[] {}); Assert.IsTrue(called); }
protected override void SubscribeToEvents(SubscribeEvent e) { application.eventManager.AddListener <PlayerOpenedMarketEvent>(this.OnMarketOpen); exitButton.onClick.AddListener(() => { this.OnExit(); }); buyButton.onClick.AddListener(() => { this.OnBuyResourceClicked(); }); sellButton.onClick.AddListener(() => { this.OnSellResourceClicked(); }); playerService = application.serviceManager.get <PlayerService>() as PlayerService; }
void OnSub(SubscribeEvent sub) { var evt = UserSubscribed; if (evt != null) { evt(this, sub.User); } }
public void Update(SubscribeEvent subscribeEvent) { foreach (var item in _observers) { if (item.SubscribeId == subscribeEvent.Id) { item.Update(subscribeEvent); } } }
public async Task Index(SubscribeEvent <StudentEvent> actionEvent) { Console.WriteLine(actionEvent.data.Guid.ToString()); var actor = ActorProxy.Create <ICollectionActor>(new ActorId("BronStudents"), "CollectionActor"); if (actionEvent.data.Action == action.Add) { Console.WriteLine($"New student added: {actionEvent.data.Guid}"); } }
public async Task Index(SubscribeEvent <EmployeeEvent> actionEvent) { Console.WriteLine(actionEvent.data.Guid.ToString()); var actor = ActorProxy.Create <ICollectionActor>(new ActorId("BronEmployees"), "CollectionActor"); if (actionEvent.data.Action == action.Add) { var response = await actor.AddGuid(actionEvent.data.Guid); } }
private string DealWithMsg(SubscribeEvent subscribeEvent) { MsgResponse msgResponse = new ContentReplyMsg() { FromUserName = subscribeEvent.ToUserName, ToUserName = subscribeEvent.FromUserName, CreateTime2 = DateTime.Now, Content = "欢迎关注公众号", MsgType = "text" }; return(messageLinkUp.GetResponseText(msgResponse)); }
public void OnMessageReceived(Node source, string msg) { logger.Write <MessageDispatcher>("Received message: " + msg); if (msg.StartsWith(SubscribeEvent.Name)) { SubscribeEvent subscription = SubscribeEvent.Deserialize(msg); addSubscription(source, subscription); sendSubscribedEvent(source, subscription); } else { broadcastMessage(source, msg); } }
private void addSubscription(Node source, SubscribeEvent subscription) { logger.Write <MessageDispatcher>($"Adding subscription from {source} to tag {subscription.Tag}"); HashSet <Node> nodesForTag; if (!subscriptions.TryGetValue(subscription.Tag, out nodesForTag)) { subscriptions.Add(subscription.Tag, new HashSet <Node> { source }); } else { subscriptions[subscription.Tag].Add(source); } }
/// <summary> /// 关注事件的处理 /// </summary> /// <param name="message"></param> /// <returns></returns> public override string HandleSubscribeEvent(SubscribeEvent message) { string result = string.Empty; var Manager = DI.DIEntity.Instance.GetImpl <IWeChatConcern>(); //根据原始ID获取关注回复 var concern = Manager.GetByOriginalId(message.ToUserName); if (concern.bIsConcernOn) { //开启关注回复 if (concern.iConcernType == 1) { //文本回复 TextRespone model = new TextRespone(message); model.Content = concern.sContent; result = ActioningRespone.Serialize(model); } if (concern.iConcernType == 2) {//图文回复 NewsRespone model = new NewsRespone(message); model.Articles.Add(new item() { Title = "测试图文消息", Description = "123456", Url = "http://www.baidu.com", PicUrl = "https://p1.ssl.qhimg.com/d/_hao360/weather/0.png" }); model.Articles.Add(new item() { Title = "测试图文消息1", Description = "555555", Url = "http://www.baidu.com", PicUrl = "https://p1.ssl.qhimg.com/d/_hao360/weather/0.png" }); model.ArticleCount = model.Articles.Count; result = ActioningRespone.Serialize(model); } } return(result); }
public RingEventBusinessHandler( IEventRegister eventRegister , IEventHandlerFactory eventHandlerFactory , ISubscribeEventStore subscribeEventStore , ILoggerFactory loggerFactory , IEventHandleSubject eventHandleSubject , int maxHandleCount) : base(maxHandleCount) { _eventRegister = eventRegister; _eventHandlerFactory = eventHandlerFactory; _subscribeEventStore = subscribeEventStore; _logger = loggerFactory.CreateLogger <RingEventBusinessHandler>(); _eventHandleSubject = eventHandleSubject; var subscribeEvent = _subscribeEventStore.Get(_defaultSubscribeId); if (subscribeEvent != null) { _subscribeEvent = subscribeEvent; } }
/// <summary> /// 事件模型 /// </summary> /// <param name="xml"></param> /// <returns></returns> private EventBase GetEventModel(XmlUtils xml) { string eventType = xml.GetValue("/xml/Event").ToLower(); EventBase message = null; switch (eventType) { case "unsubscribe": message = new UnsubscribeEvent(); break; case "subscribe": message = new SubscribeEvent(); break; case "scan": message = new ScanEvent(); break; case "location": message = new LocationEvent(); break; case "click": message = new ClickEvent(); break; case "view": message = new ViewEvent(); break; default: return(null); } return(message); }
private async Task <Channel> SubscribeToChannelAsync(string channelName, bool checkChannelList) { if (checkChannelList && _channels.ContainsKey(channelName)) { return(_channels[channelName]); } var channel = CreateChannel(channelName); var subscribeEvent = new SubscribeEvent(channelName); if (channel is PrivateChannel && _options.Authenticator == null) { throw new AuthenticatorMissingException(channelName); } if (channel is PrivateChannel) { var socketId = await GetSocketIdAsync(); var authentication = await _options.Authenticator.AuthenticateAsync(socketId, channelName); subscribeEvent.Data.Auth = authentication.Auth; subscribeEvent.Data.ChannelData = authentication.ChannelData; } if (checkChannelList) { _channels.Add(channelName, channel); } await TriggerEventAsync(subscribeEvent); if (!(channel is PresenceChannel)) { channel.Established = true; } return(channel); }
protected override void SubscribeToEvents(SubscribeEvent e) { }
public void Create() { var se = SubscribeEvent.Create("topic1", () => {}); Assert.AreEqual(se.Topics[0], "topic1"); }
protected override void SubscribeToEvents(SubscribeEvent e) { exitButton.onClick.AddListener(() => { this.OnExitLounge(); }); }
/// <summary> /// 从请求中提取微信消息推送的请求数据 /// </summary> /// <param name="request">推送过来的请求</param> /// <returns>消息推送的请求数据</returns> public MsgRequest GetMsgRequestData(WeChatEncryptMsg requestEncryptMsg) { //微信服务器在五秒内收不到响应会断掉连接,并且重新发起请求,总共重试三次 //消息排重,推荐使用msgid排重;事件类型消息推荐使用FromUserName + CreateTime 排重 //服务器无法保证在五秒内处理并回复,直接回复success;直接回复空串,微信不再重试 //开发者在5秒内未回复任何内容,开发者回复了异常数据,微信系统提示“该公众号暂时无法提供服务,请稍后再试” if (weChatConfig == null) { throw new NullReferenceException("请使用构造MessageLinkUp(idOrAppId),或初始化Initialize(idOrAppId)"); } string xmlText;//消息 if (weChatConfig.EnCrypt) { //消息是密文,要解密后处理 xmlText = MessageDecrypt(requestEncryptMsg); } else { var stream = requestEncryptMsg.Body; //具体消息数据在请求流里面 StreamReader reader = new StreamReader(stream); xmlText = reader.ReadToEnd(); //消息 reader.Close(); } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlText); XmlNode rootNode = xmlDoc.SelectSingleNode("xml"); MsgRequest msgRequest = null; if (rootNode["MsgType"] == null) { msgRequest = new MsgRequest(); } else { string msgType = rootNode["MsgType"].InnerText; switch (msgType) { case "text": ContentMsg contentMsg = new ContentMsg(); if (rootNode["MsgId"] != null) { contentMsg.MsgId = Convert.ToInt64(rootNode["MsgId"].InnerText); } if (rootNode["Content"] != null) { contentMsg.Content = rootNode["Content"].InnerText; } msgRequest = contentMsg; break; case "image": PictureMsg pictureMsg = new PictureMsg(); if (rootNode["MsgId"] != null) { pictureMsg.MsgId = Convert.ToInt64(rootNode["MsgId"].InnerText); } if (rootNode["PicUrl"] != null) { pictureMsg.PicUrl = rootNode["PicUrl"].InnerText; } if (rootNode["MediaId"] != null) { pictureMsg.MediaId = rootNode["MediaId"].InnerText; } msgRequest = pictureMsg; break; case "voice": VoiceMsg voiceMsg = new VoiceMsg(); if (rootNode["MsgId"] != null) { voiceMsg.MsgId = Convert.ToInt64(rootNode["MsgId"].InnerText); } if (rootNode["MediaId"] != null) { voiceMsg.MediaId = rootNode["MediaId"].InnerText; } if (rootNode["Format"] != null) { voiceMsg.Format = rootNode["Format"].InnerText; } if (rootNode["Recognition"] != null) { voiceMsg.Recognition = rootNode["Recognition"].InnerText; } msgRequest = voiceMsg; break; case "video": VideoMsg videoMsg = new VideoMsg(); if (rootNode["MsgId"] != null) { videoMsg.MsgId = Convert.ToInt64(rootNode["MsgId"].InnerText); } if (rootNode["MediaId"] != null) { videoMsg.MediaId = rootNode["MediaId"].InnerText; } if (rootNode["ThumbMediaId"] != null) { videoMsg.ThumbMediaId = rootNode["ThumbMediaId"].InnerText; } msgRequest = videoMsg; break; case "shortvideo": ShortVideoMsg shortVideoMsg = new ShortVideoMsg(); if (rootNode["MsgId"] != null) { shortVideoMsg.MsgId = Convert.ToInt64(rootNode["MsgId"].InnerText); } if (rootNode["MediaId"] != null) { shortVideoMsg.MediaId = rootNode["MediaId"].InnerText; } if (rootNode["ThumbMediaId"] != null) { shortVideoMsg.ThumbMediaId = rootNode["ThumbMediaId"].InnerText; } msgRequest = shortVideoMsg; break; case "location": LocationMsg locationMsg = new LocationMsg(); if (rootNode["MsgId"] != null) { locationMsg.MsgId = Convert.ToInt64(rootNode["MsgId"].InnerText); } if (rootNode["Location_X"] != null) { locationMsg.Location_X = Convert.ToDouble(rootNode["Location_X"].InnerText); } if (rootNode["Location_Y"] != null) { locationMsg.Location_Y = Convert.ToDouble(rootNode["Location_Y"].InnerText); } if (rootNode["Scale"] != null) { locationMsg.Scale = int.Parse(rootNode["Scale"].InnerText); } if (rootNode["Label"] != null) { locationMsg.Label = rootNode["Label"].InnerText; } msgRequest = locationMsg; break; case "link": LinkMsg linkMsg = new LinkMsg(); if (rootNode["MsgId"] != null) { linkMsg.MsgId = Convert.ToInt64(rootNode["MsgId"].InnerText); } if (rootNode["Title"] != null) { linkMsg.Title = rootNode["Title"].InnerText; } if (rootNode["Description"] != null) { linkMsg.Description = rootNode["Description"].InnerText; } if (rootNode["Url"] != null) { linkMsg.Url = rootNode["Url"].InnerText; } msgRequest = linkMsg; break; case "event": if (rootNode["Event"] != null) { string eventStr = rootNode["Event"].InnerText.ToLower(); switch (eventStr) { case "subscribe": if (rootNode["EventKey"] != null) { string eventKey = rootNode["EventKey"].InnerText; if (eventKey.StartsWith("qrscene_")) { ScanSubscribeEvent scanSubscribeEvent = new ScanSubscribeEvent(); scanSubscribeEvent.EventKey = eventKey; if (rootNode["Ticket"] != null) { scanSubscribeEvent.Ticket = rootNode["Ticket"].InnerText; } msgRequest = scanSubscribeEvent; } } if (msgRequest == null) { msgRequest = new SubscribeEvent(); } break; case "unsubscribe": msgRequest = new UnSubscribeEvent(); break; case "scan": ScanEvent scanEvent = new ScanEvent(); if (rootNode["EventKey"] != null) { scanEvent.EventKey = rootNode["EventKey"].InnerText; } if (rootNode["Ticket"] != null) { scanEvent.Ticket = rootNode["Ticket"].InnerText; } msgRequest = scanEvent; break; case "location": LocationEvent locationEvent = new LocationEvent(); if (rootNode["Latitude"] != null) { locationEvent.Latitude = double.Parse(rootNode["Latitude"].InnerText); } if (rootNode["Longitude"] != null) { locationEvent.Longitude = double.Parse(rootNode["Longitude"].InnerText); } if (rootNode["Precision"] != null) { locationEvent.Precision = double.Parse(rootNode["Precision"].InnerText); } msgRequest = locationEvent; break; case "click": ClickEvent clickEvent = new ClickEvent(); if (rootNode["EventKey"] != null) { clickEvent.EventKey = rootNode["EventKey"].InnerText; } msgRequest = clickEvent; break; case "view": ViewEvent viewEvent = new ViewEvent(); if (rootNode["EventKey"] != null) { viewEvent.EventKey = rootNode["EventKey"].InnerText; } msgRequest = viewEvent; break; case "masssendjobfinish": //批量发送群发消息处理完成的消息通知 MassSendJobFinishEvent sendJobFinishEvent = new MassSendJobFinishEvent(); if (rootNode["MsgID"] != null) { sendJobFinishEvent.MsgID = int.Parse(rootNode["MsgID"].InnerText); } if (rootNode["Status"] != null) { sendJobFinishEvent.Status = Enum.Parse <MassSendJobStatus>(rootNode["Status"].InnerText); } if (rootNode["TotalCount"] != null) { sendJobFinishEvent.TotalCount = int.Parse(rootNode["TotalCount"].InnerText); } if (rootNode["FilterCount"] != null) { sendJobFinishEvent.FilterCount = int.Parse(rootNode["FilterCount"].InnerText); } if (rootNode["SentCount"] != null) { sendJobFinishEvent.SentCount = int.Parse(rootNode["SentCount"].InnerText); } if (rootNode["ErrorCount"] != null) { sendJobFinishEvent.ErrorCount = int.Parse(rootNode["ErrorCount"].InnerText); } XmlNodeList checkResultList = rootNode["CopyrightCheckResult"]?.ChildNodes; if (checkResultList != null && checkResultList.Count > 0) { XmlNode countNode = rootNode["CopyrightCheckResult"]["Count"]; XmlNode checkStateNode = rootNode["CopyrightCheckResult"]["CheckState"]; XmlNode resultListNode = rootNode["CopyrightCheckResult"]["ResultList"]; if (countNode != null) { sendJobFinishEvent.CopyrightCheckCount = int.Parse(countNode.InnerText); } else if (checkStateNode != null) { sendJobFinishEvent.CheckState = int.Parse(checkStateNode.InnerText); } else if (resultListNode != null) { sendJobFinishEvent.ResultList = new List <ArticleCheckResult>(); foreach (XmlNode itemNode in resultListNode) { sendJobFinishEvent.ResultList.Add(new ArticleCheckResult() { ArticleIdx = int.Parse(itemNode["ArticleIdx"].InnerText), UserDeclareState = int.Parse(itemNode["UserDeclareState"].InnerText), AuditState = int.Parse(itemNode["AuditState"].InnerText), OriginalArticleUrl = itemNode["OriginalArticleUrl"].InnerText, OriginalArticleType = int.Parse(itemNode["OriginalArticleType"].InnerText), CanReprint = bool.Parse(itemNode["CanReprint"].InnerText), NeedReplaceContent = bool.Parse(itemNode["NeedReplaceContent"].InnerText), NeedShowReprintSource = bool.Parse(itemNode["NeedShowReprintSource"].InnerText), }); } } } msgRequest = sendJobFinishEvent; break; case "templatesendjobfinish": TemplateSendJobFinishEvent templateSendFinishEvent = new TemplateSendJobFinishEvent(); if (rootNode["MsgID"] != null) { templateSendFinishEvent.MsgID = int.Parse(rootNode["MsgID"].InnerText); } if (rootNode["Status"] != null) { templateSendFinishEvent.Status = rootNode["Status"].InnerText; } break; default: msgRequest = new MsgRequest(); break; } } break; default: msgRequest = new MsgRequest(); break; } msgRequest.MsgType = msgType; } msgRequest.ToUserName = rootNode["ToUserName"].InnerText; msgRequest.FromUserName = rootNode["FromUserName"].InnerText; msgRequest.CreateTime = int.Parse(rootNode["CreateTime"].InnerText); return(msgRequest); }
protected override void SubscribeToEvents(SubscribeEvent e) { eventManager.AddListener <PlayerOrbitStarEvent>(this.OnPlayerEnterStar); jumpButton.onClick.AddListener(() => { this.OnJump(); }); landButton.onClick.AddListener(() => { this.OnLand(); }); }
protected override void SubscribeToEvents(SubscribeEvent e) { logoutButton.onClick.AddListener(() => { this.OnLogout(); }); }
protected virtual string ProcessSubscribeEvent(SubscribeEvent msg) { return(DefaultProcess(msg)); }
protected abstract void SubscribeToEvents(SubscribeEvent e);
protected override void SubscribeToEvents(SubscribeEvent e) { chatSendButton.onClick.AddListener(() => { this.OnChatSendButtonClicked(); }); eventManager.AddListener <ChatMessageReceivedEvent>(this.OnChatMessageReceived); }
protected override Message ProcessSubscribeEvent(SubscribeEvent msg) { return(base.ProcessSubscribeEvent(msg)); }