Exemple #1
0
    private async void OnJoinRoom(object sender, JoinEvent e)
    {
        try
        {
            startMenu.enabled = false;
            GamePlay.enabled  = true;

            if (e.JoinData.JoinedMember.User.IsMe)
            {
                _me = e.JoinData.JoinedMember;
            }
            else
            {
                _opponent = e.JoinData.JoinedMember;
            }

            // Get Players Info
            if (_me == null || _opponent == null)
            {
                await GameService.GSLive.TurnBased.GetRoomMembersDetail();
            }

            // Get CurrentTurn Info
            if (_currentTurnMember == null)
            {
                await GameService.GSLive.TurnBased.GetCurrentTurnMember();
            }
        }
        catch (Exception exception)
        {
            Turn.text = "OnJoinRoom Err : " + exception.Message;
            Debug.LogError("OnJoinRoom Err : " + exception.Message);
        }
    }
Exemple #2
0
 private static void OnJoin(Message msg)
 {
     JoinEvent?.Invoke(new SystemMsgEventArgs()
     {
         msg = msg
     });
 }
Exemple #3
0
        public ActionResult JoinEvent(int id)
        {
            Event mEvent = db.Event.Find(id);

            if (mEvent == null)
            {
                return(HttpNotFound());
            }

            if (String.Compare(mEvent.Username, User.Identity.Name, true) == 0)
            {
                return(RedirectToAction("Details", "Events", new { id = id }));
            }

            var joinedUserEvent   = db.JoinEvent.Include(e => e.Event).Where(u => u.Username == User.Identity.Name).Where(e => e.EventId == id).ToList();
            var joinedFoundEvents = db.JoinEvent.Where(e => e.EventId == id).ToList();

            if (joinedFoundEvents.Count() < mEvent.Capacity && joinedUserEvent.Count == 0)
            {
                JoinEvent join = new JoinEvent();
                join.EventId  = mEvent.EventId;
                join.Username = User.Identity.Name;
                join.JoinDate = DateTime.Now;
                join.Status   = 0;

                db.JoinEvent.Add(join);
                db.SaveChanges();
            }
            else
            {
                TempData["ErrorMessage"] = "Nie możesz dołączyć do wydarzenia - nie ma już miejsc albo uczestniczysz już w tym wydarzeniu.";
            }

            return(RedirectToAction("Details", "Events", new { id = id }));
        }
Exemple #4
0
        private void On(JoinEvent e)
        {
            var p = e.Player;

            p.Connected     = true;
            p.Username      = e.Username;
            p.ConnectUserId = e.ConnectUserId;
            p.Smiley        = e.Smiley;
            p.AuraShape     = e.AuraShape;
            p.AuraColor     = e.AuraColor;
            p.Badge         = e.Badge;
            p.HasChat       = e.HasChat;
            p.GodMode       = e.God;
            p.AdminMode     = e.Admin;
            p.ModMode       = e.Mod;
            p.Friend        = e.Friend;
            p.GoldCoins     = e.Coins;
            p.BlueCoins     = e.BlueCoins;
            p.Deaths        = e.Deaths;
            p.X             = e.X;
            p.Y             = e.Y;
            p.ClubMember    = e.ClubMember;
            p.ChatColor     = e.ChatColor;
            p.Team          = e.Team;
            p.CrewMember    = e.CrewMember;
            p.GoldBorder    = e.GoldBorder;
        }
Exemple #5
0
 public void HandleJoin(JoinEvent joinEvent)
 {
     foreach (var handler in internalHandlers)
     {
         handler.HandleJoin(joinEvent);
     }
 }
Exemple #6
0
        private void On(JoinEvent e)
        {
            e.Player.SetCanPlay(true);

            e.Player.MetadataChanged += (sender, ev) =>
            {
                switch (ev.Key)
                {
                case PlayerExtensions.PlayingMetadata:
                    if ((bool)ev.NewValue)
                    {
                        new JoinRoundEvent(e.Player)
                        .RaiseIn(BotBits);
                    }
                    else
                    {
                        new LeaveRoundEvent(e.Player)
                        .RaiseIn(BotBits);
                    }
                    break;

                case PlayerExtensions.CanPlayMetadata:
                    new CanPlayEvent(e.Player, (bool)ev.NewValue).RaiseIn(BotBits);
                    break;
                }
            };
        }
        /// <summary>
        /// Handles Join event
        /// </summary>
        /// <param name="ev">JoinEvent</param>
        /// <param name="userId">UserId</param>
        /// <returns>IMessageActivity</returns>
        private IMessageActivity HandleJoin(JoinEvent ev, string userId)
        {
            var activity = GetActivityBase(userId);

            activity.ChannelData = ev;
            activity.Text        = "join";
            return(activity);
        }
Exemple #8
0
 protected override async Task OnJoinAsync(JoinEvent ev)
 {
     //参加イベント
     //Join event
     //リプライ可能 Replyable
     //https://developers.line.biz/ja/reference/messaging-api/#join-event
     //https://developers.line.biz/en/reference/messaging-api/#join-event
 }
 public void On( JoinEvent     e )
 {
     if ( e.Who.Nick == CurrentNickname ) foreach ( var channel in e.AffectedChannels ) {
         GetChannelInfo(channel).Joined = true;
     } else foreach ( var channel in e.AffectedChannels ) {
         GetChannelInfo(channel).People.Add( new ChannelInfo.Person() { Sigil="", NUH=e.Who } );
     }
 }
Exemple #10
0
        private void OnJoinRoom(object sender, JoinEvent e)
        {
            Debug.Log("OnJoinRoom : " + e.JoinData.JoinedMember.Name);
            var activeScene = SceneManager.GetActiveScene();

            // Go To GameScene When Joined To Room
            if (activeScene.name == "MenuScene")
            {
                SceneManager.LoadScene("GameScene");
            }
        }
    public void SendJoin(int quality)
    {
        JoinEvent join = JoinEvent.Create();
        string    id   = "P" + (nextId);

        nextId       += 1;
        myPlayerId    = id;
        join.Index    = numOfPlayer;
        join.PlayerID = id;
        join.Quality  = quality;
        join.Send();
    }
Exemple #12
0
    public static void JoinServer()
    {
        //Currently only joining local host
        client = new NetManager(listener);
        client.Start();
        client.Connect("127.0.0.1", 3213, "");
        IsConnected = true;
        JoinEvent join = new JoinEvent();

        join.value = "Hi jerry, this is your captain speaking.";
        Networker.AddPacket(join);

        IsServer = false;
    }
Exemple #13
0
        public ActionResult RemoveFromEvent(int idJoin, int idEvent)
        {
            JoinEvent join = db.JoinEvent.Find(idJoin);

            if (join == null)
            {
                return(HttpNotFound());
            }

            db.JoinEvent.Remove(join);
            db.SaveChanges();

            return(RedirectToAction("ShowGuests", new { id = idEvent }));
        }
        private void OnMessageReceived(object sender, MessageReceivedEventArgs e)
        {
            var message = JsonConvert.DeserializeObject <Message>(e.Message);

            switch (message.Header)
            {
            case "Join":
                var joinRes = JsonConvert.DeserializeObject <JoinRes>(message.Body);
                JoinEvent?.Invoke(this, new JoinEventArgs
                {
                    JoinRes = joinRes
                });
                break;

            case "Hand":
                var handRes = JsonConvert.DeserializeObject <HandRes>(message.Body);
                HandEvent?.Invoke(this, new HandEventArgs
                {
                    HandRes = handRes
                });
                break;

            case "Tsumo":
                var tsumoRes = JsonConvert.DeserializeObject <TsumoRes>(message.Body);
                TsumoEvent?.Invoke(this, new TsumoEventArgs
                {
                    TsumoRes = tsumoRes
                });
                break;

            case "Dahai":
                var dahaiRes = JsonConvert.DeserializeObject <DahaiRes>(message.Body);
                DahaiEvent?.Invoke(this, new DahaiEventArgs
                {
                    DahaiRes = dahaiRes
                });
                break;

            case "Agari":
                var agariRes = JsonConvert.DeserializeObject <AgariRes>(message.Body);
                AgariEvent?.Invoke(this, new AgariEventArgs
                {
                    AgariRes = agariRes
                });
                break;

            default:
                break;
            }
        }
Exemple #15
0
        public ActionResult JoinEvent(int id)
        {
            Event mEvent = db.Event.Find(id);

            if (mEvent == null)
            {
                return(HttpNotFound());
            }

            if (String.Compare(mEvent.Username, User.Identity.Name, true) == 0)
            {
                return(RedirectToAction("Details", "Events", new { id = id }));
            }

            //sprawdzenie daty rejestracji
            if (DateTime.Compare(DateTime.Now.Date, mEvent.DateBeginRegistation.Date) <= 0 || DateTime.Compare(DateTime.Now.Date, mEvent.DateEndRegistation.Date) >= 0)
            {
                DateTime begin = DateTime.Parse(mEvent.HourBeginRegistration);
                DateTime end   = DateTime.Parse(mEvent.HourEndRegistration);

                //spr. czasu rejestracji
                if (Int32.Parse(DateTime.Now.Hour.ToString()) <= Int32.Parse(begin.Hour.ToString()) || (Int32.Parse(DateTime.Now.Hour.ToString()) <= Int32.Parse(begin.Hour.ToString()) && Int32.Parse(DateTime.Now.Minute.ToString()) <= Int32.Parse(begin.Minute.ToString())) || Int32.Parse(DateTime.Now.Hour.ToString()) > Int32.Parse(end.Hour.ToString()) || (Int32.Parse(DateTime.Now.Hour.ToString()) > Int32.Parse(end.Hour.ToString()) && Int32.Parse(DateTime.Now.Minute.ToString()) > Int32.Parse(end.Minute.ToString())))
                {
                    TempData["ErrorMessage"] = "Nie możesz dołączyć do wydarzenia - rejestracja jest zamknięta.";
                    return(RedirectToAction("Details", "Events", new { id = id }));
                }
            }

            var joinedUserEvent   = db.JoinEvent.Include(e => e.Event).Where(u => u.Username == User.Identity.Name).Where(e => e.EventId == id).ToList();
            var joinedFoundEvents = db.JoinEvent.Where(e => e.EventId == id).ToList();

            if (joinedFoundEvents.Count() < mEvent.Capacity && joinedUserEvent.Count == 0)
            {
                JoinEvent join = new JoinEvent();
                join.EventId  = mEvent.EventId;
                join.Username = User.Identity.Name;
                join.JoinDate = DateTime.Now;
                join.Status   = 0;

                db.JoinEvent.Add(join);
                db.SaveChanges();
            }
            else
            {
                TempData["ErrorMessage"] = "Nie możesz dołączyć do wydarzenia - nie ma już miejsc albo uczestniczysz już w tym wydarzeniu.";
            }

            return(RedirectToAction("Details", "Events", new { id = id }));
        }
Exemple #16
0
        /// <summary>
        ///   Sends a <see cref = "JoinEvent" /> to all <see cref = "Actor" />s.
        /// </summary>
        /// <param name = "peer">
        ///   The peer.
        /// </param>
        /// <param name = "joinRequest">
        ///   The join request.
        /// </param>
        protected virtual void PublishJoinEvent(LitePeer peer, JoinRequest joinRequest)
        {
            Actor actor = this.GetActorByPeer(peer);

            if (actor == null)
            {
                return;
            }

            // generate a join event and publish to all actors in the room
            var joinEvent = new JoinEvent(actor.ActorNr, this.Actors.GetActorNumbers().ToArray());

            if (joinRequest.BroadcastActorProperties)
            {
                joinEvent.ActorProperties = joinRequest.ActorProperties;
            }

            this.PublishEvent(joinEvent, this.Actors, new SendParameters());
        }
Exemple #17
0
        private void OnJoin(JoinEvent e)
        {
            Player p = e.Player;

            p.Connected  = true;
            p.Username   = e.Username;
            p.Smiley     = e.Smiley;
            p.Aura       = e.Aura;
            p.HasChat    = e.HasChat;
            p.GodMode    = e.God;
            p.AdminMode  = e.Admin;
            p.ModMode    = e.Mod;
            p.Friend     = e.Friend;
            p.GoldCoins  = e.Coins;
            p.BlueCoins  = e.BlueCoins;
            p.X          = e.X;
            p.Y          = e.Y;
            p.ClubMember = e.ClubMember;
            p.ChatColor  = e.ChatColor;
            p.Team       = e.Team;
        }
Exemple #18
0
        private void On(JoinEvent e)
        {
            var p = e.Player;

            p.Connected     = true;
            p.Username      = e.Username;
            p.ConnectUserId = e.ConnectUserId;
            p.Smiley        = e.Smiley;
            p.AuraShape     = e.AuraShape;
            p.AuraColor     = e.AuraColor;
            p.StaffAura     = e.StaffAura;
            p.Badge         = e.Badge;
            p.HasChat       = e.HasChat;
            p.GodMode       = e.GodMode;
            p.AdminMode     = e.AdminMode;
            p.ModMode       = e.Mod;
            p.Friend        = e.Friend;
            p.GoldCoins     = e.Coins;
            p.BlueCoins     = e.BlueCoins;
            p.Deaths        = e.Deaths;
            p.X             = e.X;
            p.Y             = e.Y;
            p.GoldMember    = e.GoldMember;
            p.ChatColor     = e.ChatColor;
            p.Team          = e.Team;
            p.CrewMember    = e.CrewMember;
            p.GoldBorder    = e.GoldBorder;
            p.HasEditRights = e.HasEditRights;
            p.HasGodRights  = e.HasGodRights;

            // Load the purple switcches
            foreach (var ps in e.PurpleSwitches)
            {
                p.AddSwitch(ps);
                new PurpleSwitchEvent(p, ps, true)
                .RaiseIn(this.BotBits);
            }
        }
Exemple #19
0
        private void OnJoin(JoinEvent e)
        {
            Program.DebugLog("on Join");
            if (!ProposalExists(e.PostedChannel.Id)) //if there is already an active proposal
            {
                return;
            }

            var proposal = _proposals[e.PostedChannel.Id];

            if (proposal.WhiteSide == null)
            {
                OnJoinSide(e.ToJoinSideEvent(true));
            }
            else if (proposal.BlackSide == null)
            {
                OnJoinSide(e.ToJoinSideEvent(false));
            }
            else
            {
                throw new AggregateException("not deleting proposals correctly after game has already started?");
            }
        }
        private void OnMessageReceived(object sender, MessageReceivedEventArgs e)
        {
            var message = JsonConvert.DeserializeObject <Message>(e.Message);

            switch (message.Header)
            {
            case "Join":
                var joinReq = JsonConvert.DeserializeObject <JoinReq>(message.Body);
                JoinEvent?.Invoke(this, new JoinEventArgs(joinReq));
                ResponseJoin();
                Start();
                break;

            case "Hand":
                var handReq = JsonConvert.DeserializeObject <HandReq>(message.Body);
                ResponseHand();
                break;

            case "Tsumo":
                var tsumoReq = JsonConvert.DeserializeObject <TsumoReq>(message.Body);
                ResponseTsumo();
                break;

            case "Dahai":
                var dahaiReq = JsonConvert.DeserializeObject <DahaiReq>(message.Body);
                ResponseDahai(dahaiReq.Index);
                break;

            case "Agari":
                var agariReq = JsonConvert.DeserializeObject <AgariReq>(message.Body);
                ResponseAgari();
                break;

            default:
                break;
            }
        }
Exemple #21
0
        protected virtual async void OnJoin(string source, string target)
        {
            string nick = source.GetNickFromSource();
            bool   me   = _currentNick.EqualsIgnoreCase(nick);

            if (me && FillListsOnJoin)
            {
                FillChannelLists(target);
            }

            if (StrictNames || me)
            {
                await Send("NAMES {0}", target);
            }

            var c = GetChannel(target);

            if (!c.HasUser(nick))
            {
                c.AddOrUpdateUser(nick);
            }

            JoinEvent.Raise(this, new JoinPartEventArgs(nick, target, me: me));
        }
Exemple #22
0
        void manager_UnhandledEvent(object sender, ManagerEvent e)
        {
            log.Debug("New unhandled event received: " + e.GetType().Name);
            LineControl lc = null;

            //StateServer
            switch (e.GetType().Name)
            {
            case "AGIExecEvent":
                AGIExecEvent agievent = e as AGIExecEvent;
                break;

            case "AlarmClearEvent":
                AlarmClearEvent alarmclear = e as AlarmClearEvent;
                break;

            case "AlarmEvent":
                AlarmEvent alarmevent = e as AlarmEvent;
                break;

            case "AsyncAGIEvent":
                AsyncAGIEvent asyncagievent = e as AsyncAGIEvent;
                break;

            case "BridgeEvent":
                BridgeEvent bridgeevent = e as BridgeEvent;
                break;

            case "CdrEvent":
                CdrEvent cdrevent = e as CdrEvent;
                break;

            case "ChannelReloadEvent":
                ChannelReloadEvent channelreload = e as ChannelReloadEvent;
                break;

            case "ChannelUpdateEvent":
                ChannelUpdateEvent channelupdate = e as ChannelUpdateEvent;
                break;

            case "ConnectEvent":
                ConnectEvent connectevent = e as ConnectEvent;
                break;

            case "ConnectionStateEvent":
                ConnectionStateEvent connectionstate = e as ConnectionStateEvent;
                break;

            case "DBGetResponseEvent":
                DBGetResponseEvent dbget = e as DBGetResponseEvent;
                log.Debug("DBGet response: " + dbget.ToString());
                switch (dbget.Family)
                {
                case "DND":
                    ss.SetLineControl(setLineControlDND(dbget.Key, true));
                    break;

                case "CF":
                    ss.SetLineControl(setLineControlForward(dbget.Key, dbget.Val));
                    break;
                }
                break;

            case "DialEvent":
                DialEvent dial = e as DialEvent;
                log.Debug("Dial event: " + dial.ToString());
                break;

            case "DisconnectEvent":
                DisconnectEvent disconnect = e as DisconnectEvent;
                log.Debug("Disconnect event: " + disconnect.ToString());
                break;

            case "DNDStateEvent":
                DNDStateEvent dndstate = e as DNDStateEvent;
                log.Debug("DND state event: " + dndstate.ToString());
                break;

            case "ExtensionStatusEvent":
                ExtensionStatusEvent extensionstatus = e as ExtensionStatusEvent;
                log.Debug("Extension status event: " + extensionstatus.ToString() + ", status: " + extensionstatus.Status + ", hint: " + extensionstatus.Hint);
                ss.SetLineControl(getLineControlFromExtensionStatusEvent(extensionstatus));
                break;

            case "FaxReceivedEvent":
                FaxReceivedEvent faxreceived = e as FaxReceivedEvent;
                break;

            case "HangupEvent":
                HangupEvent hangup = e as HangupEvent;
                log.Debug("Hangup event: " + hangup.ToString() + " callerid: " + hangup.CallerId + " calleridnum: " + hangup.CallerIdNum);
                //line control
                if (channels.Contains(hangup.Channel))
                {
                    lc = getLineControl((string)channels[hangup.Channel]);
                    int hi = 0;
                    LineControlConnection[] newLCC = null;
                    if (lc.lineControlConnection.Length > 1)
                    {
                        newLCC = new LineControlConnection[lc.lineControlConnection.Length - 1];
                        foreach (LineControlConnection hlcc in lc.lineControlConnection)
                        {
                            if (hlcc.callid != hangup.Channel)
                            {
                                newLCC[hi] = hlcc;
                                hi++;
                            }
                        }
                    }
                    lc.lineControlConnection = newLCC;
                    ss.SetLineControl(lc);
                    channels.Remove(hangup.Channel);
                }

                //missed calls
                callToFind = hangup.UniqueId.Substring(0, 6) + "," + hangup.UniqueId.Substring(6);
                Call mCall = missedCalls.Find(FindCall);
                if (mCall != null)
                {
                    log.Debug("Missed call finded for callid: " + hangup.UniqueId);
                    AddCallLogs(mCall.callee, mCall);
                    if (missedCalls.Remove(mCall))
                    {
                        log.Debug("Call " + mCall.callId + " successfully removed from missedcall cache");
                    }
                    else
                    {
                        log.Debug("Call " + mCall.callId + " cannot be removed from missedcall cache");
                    }
                }
                break;

            case "HoldedCallEvent":
                HoldedCallEvent holdedcall = e as HoldedCallEvent;
                break;

            case "HoldEvent":
                HoldEvent holdevent = e as HoldEvent;
                break;

            case "JabberEvent":
                JabberEvent jabberevent = e as JabberEvent;
                break;

            case "JitterBufStatsEvent":
                JitterBufStatsEvent jitter = e as JitterBufStatsEvent;
                break;

            case "JoinEvent":
                JoinEvent join = e as JoinEvent;
                break;

            case "LeaveEvent":
                LeaveEvent leave = e as LeaveEvent;
                break;

            case "LinkEvent":
                LinkEvent link = e as LinkEvent;
                log.Debug("Link event: " + link.ToString());
                lc = getLineControl(link.CallerId1);
                if (lc != null)
                {
                    foreach (LineControlConnection linklcc in lc.lineControlConnection)
                    {
                        if (linklcc.callid == link.Channel1)
                        {
                            linklcc.contact = link.CallerId2;
                            ss.SetLineControl(lc);
                            break;
                        }
                    }
                }
                lc = getLineControl(link.CallerId2);
                if (lc != null)
                {
                    foreach (LineControlConnection linklcc in lc.lineControlConnection)
                    {
                        if (linklcc.callid == link.Channel2)
                        {
                            linklcc.contact = link.CallerId1;
                            ss.SetLineControl(lc);
                            break;
                        }
                    }
                }
                break;

            case "LogChannelEvent":
                LogChannelEvent logchannel = e as LogChannelEvent;
                break;

            case "ManagerEvent":
                ManagerEvent managerevent = e;
                break;

            case "MeetmeEndEvent":
                MeetmeEndEvent meetmeend = e as MeetmeEndEvent;
                break;

            case "MeetmeJoinEvent":
                MeetmeJoinEvent meetmejoin = e as MeetmeJoinEvent;
                break;

            case "MeetmeLeaveEvent":
                MeetmeLeaveEvent meetmeleave = e as MeetmeLeaveEvent;
                break;

            case "MeetmeMuteEvent":
                MeetmeMuteEvent meetmemute = e as MeetmeMuteEvent;
                break;

            case "MeetmeStopTalkingEvent":
                MeetmeStopTalkingEvent meetmestoptalking = e as MeetmeStopTalkingEvent;
                break;

            case "MeetmeTalkingEvent":
                MeetmeTalkingEvent meetmetalking = e as MeetmeTalkingEvent;
                break;

            case "MeetmeTalkRequestEvent":
                MeetmeTalkRequestEvent meetmetalkrequest = e as MeetmeTalkRequestEvent;
                break;

            case "MessageWaitingEvent":
                MessageWaitingEvent messagewaiting = e as MessageWaitingEvent;
                log.Debug("Message waiting event: " + messagewaiting.ToString());
                lc = getLineControl(messagewaiting.Mailbox.Substring(0, messagewaiting.Mailbox.IndexOf("@")));
                if (lc != null)
                {
                    if (messagewaiting.Waiting > 0)
                    {
                        lc.mwiOn = true;
                    }
                    else
                    {
                        lc.mwiOn = false;
                    }
                    ss.SetLineControl(lc);
                }
                break;

            case "MobileStatusEvent":
                MobileStatusEvent mobilestatus = e as MobileStatusEvent;
                break;

            case "ModuleLoadReportEvent":
                ModuleLoadReportEvent moduleload = e as ModuleLoadReportEvent;
                break;

            case "MonitorStartEvent":
                MonitorStartEvent monitorstart = e as MonitorStartEvent;
                break;

            case "MonitorStopEvent":
                MonitorStopEvent monitorstop = e as MonitorStopEvent;
                break;

            case "NewAccountCodeEvent":
                NewAccountCodeEvent newaccountcode = e as NewAccountCodeEvent;
                break;

            case "NewCallerIdEvent":
                NewCallerIdEvent newcallerid = e as NewCallerIdEvent;
                log.Debug("New caller id envent: " + newcallerid.ToString());
                break;

            case "NewChannelEvent":
                NewChannelEvent newchannel = e as NewChannelEvent;
                log.Debug("New Channel event: " + newchannel.ToString());
                CommandAction   ca = new CommandAction("core show channel " + newchannel.Channel);
                CommandResponse cr = (CommandResponse)manager.SendAction(ca, 10000);
                log.Debug("Channel info: " + cr.ToString());
                string dn = newchannel.CallerIdNum;
                log.Debug("Retreive call information...");
                bool callerIdUnknown = true;
                if (newchannel.CallerIdNum != "<unknown>")
                {
                    callerIdUnknown = false;
                }
                else
                {
                    foreach (string s in cr.Result)
                    {
                        if (s.Contains("Caller ID:"))
                        {
                            dn = s.Substring(s.LastIndexOf(" "));
                            break;
                        }
                    }
                }
                Call newOutboundCall = getOutboundCallFromChannelInfo(cr.Result, callerIdUnknown);
                if (newOutboundCall != null)
                {
                    Call missedCall = newOutboundCall;
                    AddCallLogs(dn, newOutboundCall);
                    dnToFind = newOutboundCall.callee;
                    if (linecontrols.Find(FindLineControl) != null)
                    {
                        log.Debug("This call will be put in missedcall cache: " + missedCall.callId);
                        missedCall.type = CallType.missed;
                        missedCalls.Add(missedCall);
                    }
                }
                break;

            case "NewExtenEvent":
                NewExtenEvent newexten = e as NewExtenEvent;
                log.Debug("New exten event: " + newexten.ToString());
                string   channel      = "";
                char[]   splitter     = { '/' };
                string[] splitchannel = newexten.Channel.Split(splitter);
                splitter[0]  = '-';
                splitchannel = splitchannel[1].Split(splitter);
                channel      = splitchannel[0];
                //DND?
                if (newexten.Extension == Properties.Settings.Default.FeatureCodeDNDToggle && newexten.Application == "Playback")
                {
                    switch (newexten.AppData)
                    {
                    case "do-not-disturb&activated":
                        log.Debug("Successfully activate dnd for channel: " + channel);
                        ss.SetLineControl(setLineControlDND(channel, true));
                        break;

                    case "do-not-disturb&de-activated":
                        log.Debug("Successfully deactivate dnd for channel: " + channel);
                        ss.SetLineControl(setLineControlDND(channel, false));
                        break;
                    }
                }
                //Forward all?
                else if (newexten.Extension.Contains(Properties.Settings.Default.FeatureCodeCallForwardAllActivate) && newexten.Application == "Playback" && newexten.AppData == "call-fwd-unconditional&for&extension")
                {
                    string forward = newexten.Extension.Substring(Properties.Settings.Default.FeatureCodeCallForwardAllActivate.Length);
                    log.Debug("Call forward all from channel: " + channel + " to " + forward);
                    ss.SetLineControl(setLineControlForward(channel, forward));
                }
                // UnForwardAll
                else if (newexten.Extension == Properties.Settings.Default.FeatureCodeCallForwardAllDeactivate && newexten.Application == "Playback" && newexten.AppData == "call-fwd-unconditional&de-activated")
                {
                    log.Debug("Call unforward all from channel: " + channel);
                    ss.SetLineControl(setLineControlForward(channel, ""));
                }
                break;

            case "NewStateEvent":
                NewStateEvent newstate = e as NewStateEvent;
                log.Debug("New State event: " + newstate.ToString());
                LineControl             newstateLc   = getLineControl(newstate.CallerId);
                LineControlConnection[] newStateLccs = null;
                int i = 0;
                if (newstateLc.lineControlConnection != null)
                {
                    bool isContained = false;
                    foreach (LineControlConnection elcc in newstateLc.lineControlConnection)
                    {
                        if (elcc.callid == newstate.Channel)
                        {
                            isContained  = true;
                            newStateLccs = newstateLc.lineControlConnection;
                            break;
                        }
                        i++;
                    }
                    if (!isContained)
                    {
                        i            = 0;
                        newStateLccs = new LineControlConnection[newstateLc.lineControlConnection.Length + 1];
                        foreach (LineControlConnection newstateLcc in newstateLc.lineControlConnection)
                        {
                            newStateLccs[i] = newstateLcc;
                            i++;
                        }
                    }
                }
                else
                {
                    newStateLccs    = new LineControlConnection[1];
                    newStateLccs[0] = new LineControlConnection();
                }
                try
                {
                    switch (newstate.State)
                    {
                    case "Up":
                        //received call?
                        callToFind = newstate.UniqueId;
                        Call rCall = missedCalls.Find(FindCall);
                        if (rCall != null)
                        {
                            log.Debug("Missed call finded: " + callToFind + ", this call will be received");
                            rCall.type = CallType.received;
                            AddCallLogs(rCall.callee, rCall);
                            missedCalls.Remove(rCall);
                        }
                        if (newStateLccs != null)
                        {
                            if (!channels.Contains(newstate.Channel))
                            {
                                channels.Add(newstate.Channel, newstate.CallerId);
                            }
                            newStateLccs[i].callid        = newstate.Channel;
                            newStateLccs[i].remoteState   = Wybecom.TalkPortal.CTI.Proxy.ConnectionState.established;
                            newStateLccs[i].state         = Wybecom.TalkPortal.CTI.Proxy.ConnectionState.established;
                            newStateLccs[i].terminalState = TerminalState.talking;
                        }
                        break;

                    case "Ringing":
                        if (newStateLccs != null)
                        {
                            if (!channels.Contains(newstate.Channel))
                            {
                                channels.Add(newstate.Channel, newstate.CallerId);
                            }
                            newStateLccs[i].callid        = newstate.Channel;
                            newStateLccs[i].remoteState   = Wybecom.TalkPortal.CTI.Proxy.ConnectionState.established;
                            newStateLccs[i].state         = Wybecom.TalkPortal.CTI.Proxy.ConnectionState.alerting;
                            newStateLccs[i].terminalState = TerminalState.ringing;
                        }
                        break;

                    case "Ring":
                        if (newStateLccs != null)
                        {
                            if (!channels.Contains(newstate.Channel))
                            {
                                channels.Add(newstate.Channel, newstate.CallerId);
                            }
                            newStateLccs[i].callid        = newstate.Channel;
                            newStateLccs[i].remoteState   = Wybecom.TalkPortal.CTI.Proxy.ConnectionState.alerting;
                            newStateLccs[i].state         = Wybecom.TalkPortal.CTI.Proxy.ConnectionState.dialing;
                            newStateLccs[i].terminalState = TerminalState.inuse;
                        }
                        break;
                    }
                }
                catch (Exception stateException)
                {
                    log.Debug("NewState exception: " + stateException.Message);
                }
                if (newstateLc != null)
                {
                    newstateLc.lineControlConnection = newStateLccs;
                    ss.SetLineControl(newstateLc);
                }
                break;

            case "OriginateResponseEvent":
                OriginateResponseEvent originateresponse = e as OriginateResponseEvent;
                break;

            case "ParkedCallEvent":
                ParkedCallEvent parkedcall = e as ParkedCallEvent;
                break;

            case "ParkedCallGiveUpEvent":
                ParkedCallGiveUpEvent parkedcallgiveup = e as ParkedCallGiveUpEvent;
                break;

            case "ParkedCallsCompleteEvent":
                ParkedCallsCompleteEvent parkedcallscomplete = e as ParkedCallsCompleteEvent;
                break;

            case "ParkedCallTimeOutEvent":
                ParkedCallTimeOutEvent parkedcalltimeout = e as ParkedCallTimeOutEvent;
                break;

            case "PeerEntryEvent":
                log.Debug("SipAction: one peer entry event received, " + e.ToString());
                PeerEntryEvent peerentry = e as PeerEntryEvent;
                peers.Add(peerentry);
                ss.SetLineControl(getLineControlFromPeerEntry(peerentry));
                break;

            case "PeerlistCompleteEvent":
                log.Debug("SipAction: peer list completed " + e.ToString());
                PeerlistCompleteEvent peerlistcomplete = e as PeerlistCompleteEvent;
                acs.setPeers(peers);
                break;

            case "PeerStatusEvent":
                PeerStatusEvent peerstatus = e as PeerStatusEvent;
                log.Debug("Peer status: " + peerstatus.ToString());
                break;

            case "PRIEvent":
                PRIEvent pri = e as PRIEvent;
                break;

            case "RegistryEvent":
                RegistryEvent registry = e as RegistryEvent;
                break;

            case "ReloadEvent":
                ReloadEvent reload = e as ReloadEvent;
                break;

            case "RenameEvent":
                RenameEvent rename = e as RenameEvent;
                break;

            case "ResponseEvent":
                ResponseEvent response = e as ResponseEvent;
                break;

            case "RTCPReceivedEvent":
                RTCPReceivedEvent rtcpreceived = e as RTCPReceivedEvent;
                break;

            case "RTCPSentEvent":
                RTCPSentEvent rtcpsent = e as RTCPSentEvent;
                break;

            case "RTPReceiverStatEvent":
                RTPReceiverStatEvent rtpreceiver = e as RTPReceiverStatEvent;
                break;

            case "RTPSenderStatEvent":
                RTPSenderStatEvent rtpsender = e as RTPSenderStatEvent;
                break;

            case "ShowDialPlanCompleteEvent":
                ShowDialPlanCompleteEvent showdialplan = e as ShowDialPlanCompleteEvent;
                break;

            case "ShutdownEvent":
                ShutdownEvent shutdown = e as ShutdownEvent;
                break;

            case "StatusCompleteEvent":
                StatusCompleteEvent statuscomplete = e as StatusCompleteEvent;
                break;

            case "StatusEvent":
                StatusEvent status = e as StatusEvent;
                break;

            case "TransferEvent":
                TransferEvent transfer = e as TransferEvent;
                break;

            case "UnholdEvent":
                UnholdEvent unhold = e as UnholdEvent;
                break;

            case "UnknownEvent":
                UnknownEvent unknown = e as UnknownEvent;
                break;

            case "UnlinkEvent":
                UnlinkEvent unlink = e as UnlinkEvent;
                log.Debug("Unlink event : " + unlink.ToString());
                LineControlConnection[] lccs = null;
                i  = 0;
                lc = getLineControl(unlink.CallerId1);
                if (lc != null)
                {
                    if (lc.lineControlConnection.Length > 1)
                    {
                        lccs = new LineControlConnection[lc.lineControlConnection.Length - 1];
                        foreach (LineControlConnection linklcc in lc.lineControlConnection)
                        {
                            if (linklcc.callid != unlink.Channel1)
                            {
                                lccs[i] = linklcc;
                                i++;
                                break;
                            }
                        }
                    }
                    else
                    {
                        lc.lineControlConnection = null;
                    }
                    ss.SetLineControl(lc);
                }
                i  = 0;
                lc = getLineControl(unlink.CallerId2);
                if (lc != null)
                {
                    if (lc.lineControlConnection.Length > 1)
                    {
                        lccs = new LineControlConnection[lc.lineControlConnection.Length - 1];
                        foreach (LineControlConnection linklcc in lc.lineControlConnection)
                        {
                            if (linklcc.callid != unlink.Channel2)
                            {
                                lccs[i] = linklcc;
                                i++;
                                break;
                            }
                        }
                    }
                    else
                    {
                        lc.lineControlConnection = null;
                    }
                    ss.SetLineControl(lc);
                }
                break;

            case "UnparkedCallEvent":
                UnparkedCallEvent unparked = e as UnparkedCallEvent;
                break;

            case "UserEvent":
                UserEvent user = e as UserEvent;
                break;

            case "VarSetEvent":
                VarSetEvent varset = e as VarSetEvent;
                break;

            case "ZapShowChannelsCompleteEvent":
                ZapShowChannelsCompleteEvent zapshowchannelscomplete = e as ZapShowChannelsCompleteEvent;
                break;

            case "ZapShowChannelsEvent":
                ZapShowChannelsEvent zapshowchannels = e as ZapShowChannelsEvent;
                break;
            }
            //ACDConnector
            switch (e.GetType().Name)
            {
            case "AgentCallbackLoginEvent":
                AgentCallbackLoginEvent agentcallbacklogin = e as AgentCallbackLoginEvent;
                break;

            case "AgentCallbackLogoffEvent":
                AgentCallbackLogoffEvent agentcallbacklogoff = e as AgentCallbackLogoffEvent;
                break;

            case "AgentCalledEvent":
                AgentCalledEvent agentcalled = e as AgentCalledEvent;
                break;

            case "AgentCompleteEvent":
                AgentCompleteEvent agentcomplete = e as AgentCompleteEvent;
                break;

            case "AgentConnectEvent":
                AgentConnectEvent agentconnect = e as AgentConnectEvent;
                break;

            case "AgentDumpEvent":
                AgentDumpEvent agentdump = e as AgentDumpEvent;
                break;

            case "AgentLoginEvent":
                AgentLoginEvent agentlogin = e as AgentLoginEvent;
                break;

            case "AgentLogoffEvent":
                AgentLogoffEvent agentlogoff = e as AgentLogoffEvent;
                break;

            case "AgentsCompleteEvent":
                AgentsCompleteEvent agentscomplete = e as AgentsCompleteEvent;
                break;

            case "AgentsEvent":
                AgentsEvent agentevent = e as AgentsEvent;
                break;

            case "QueueCallerAbandonEvent":
                QueueCallerAbandonEvent queuecallerabandon = e as QueueCallerAbandonEvent;
                break;

            case "QueueEntryEvent":
                QueueEntryEvent queueentry = e as QueueEntryEvent;
                break;

            case "QueueEvent":
                QueueEvent queue = e as QueueEvent;
                break;

            case "QueueMemberEvent":
                QueueMemberEvent queuemember = e as QueueMemberEvent;
                break;

            case "QueueMemberPausedEvent":
                QueueMemberPausedEvent queuememberpaused = e as QueueMemberPausedEvent;
                break;

            case "QueueMemberPenaltyEvent":
                QueueMemberPenaltyEvent queuememberpenalty = e as QueueMemberPenaltyEvent;
                break;

            case "QueueMemberRemovedEvent":
                QueueMemberRemovedEvent queuememberremoved = e as QueueMemberRemovedEvent;
                break;

            case "QueueMemberStatusEvent":
                QueueMemberStatusEvent queuememberstatus = e as QueueMemberStatusEvent;
                break;

            case "QueueParamsEvent":
                QueueParamsEvent queueparams = e as QueueParamsEvent;
                break;

            case "QueueStatusCompleteEvent":
                QueueStatusCompleteEvent queuestatuscomplete = e as QueueStatusCompleteEvent;
                break;
            }
        }
Exemple #23
0
 void On(JoinEvent e)
 {
     Chat.Say("Hi {0}", e.Player.Username);
 }
Exemple #24
0
 static void OnJoin(JoinEvent e)
 {
     Chat.Of(bot).PrivateMessage(e.Player, e.Username);
 }
Exemple #25
0
        public async Task <IActionResult> Post([FromBody] JoinEvent command)
        {
            await SendAsync(command);

            return(NoContent());
        }
Exemple #26
0
 public void On( JoinEvent     e )
 {
 }
Exemple #27
0
 private void On(JoinEvent e)
 {
     CheckRoundStart();
 }
Exemple #28
0
 protected override async Task OnJoinAsync(JoinEvent ev)
 {
     log.LogInformation("OnJoin");
     await InsertOrReplaceAccount(ev);
 }
 protected override async Task OnJoinAsync(JoinEvent ev)
 {
     Log.WriteInfo($"SourceType:{ev.Source.Type}, SourceId:{ev.Source.Id}");
     await MessagingClient.ReplyMessageAsync(ev.ReplyToken, $"Thank you for letting me join your {ev.Source.Type.ToString().ToLower()}!");
 }
Exemple #30
0
 public static void OnJoin(JoinEvent ev)
 {
     ev.Player.GameObject.AddComponent <RainbowTagController>();
 }
Exemple #31
0
        private ChatEvent ParseLine(string aline, bool isClientFileLine = true)
        {
            log.Trace($"Parsing line {aline} from {(isClientFileLine ? "Client file" : "Clipboard")}");
            ChatEvent evt       = null;
            bool      processed = false;

            foreach (var line in new List <string> {
                aline
            })
            {
                Offer offer = new Offer();

                // Time
                if (isClientFileLine)
                {
                    int timeIndex = line.IndexOf(" ");

                    if (timeIndex == -1)
                    {
                        continue;
                    }

                    timeIndex = line.IndexOf(" ", timeIndex + 1);

                    if (timeIndex == -1)
                    {
                        continue;
                    }

                    var strTime = line.Substring(0, timeIndex);

                    if (string.IsNullOrEmpty(strTime) || string.IsNullOrWhiteSpace(strTime))
                    {
                        continue;
                    }

                    DateTime date;

                    if (!DateTime.TryParse(strTime.Replace("/", "-"), out date))
                    {
                        continue;
                    }

                    offer.Time = date;
                }
                else
                {
                    offer.Time = DateTime.Now;
                }

                // Player name
                bool alternatePlayerEndIndex = false;
                int  playerStartIndex        = line.IndexOf("@From ");

                if (playerStartIndex == -1)
                {
                    playerStartIndex = line.IndexOf("@To ");

                    if (playerStartIndex == -1)
                    {
                        playerStartIndex        = line.IndexOf("@");
                        alternatePlayerEndIndex = true;

                        if (playerStartIndex == -1)
                        {
                            continue;
                        }
                    }

                    offer.IsOutgoing  = true;
                    playerStartIndex += 4;
                }
                else
                {
                    playerStartIndex += 6;
                }

                int playerEndIndex = -1;

                playerEndIndex = line.IndexOf(alternatePlayerEndIndex ? " Hi" : ": ", playerStartIndex);

                if (playerEndIndex == -1)
                {
                    continue;
                }

                offer.PlayerName = line.Substring(playerStartIndex, playerEndIndex - playerStartIndex);

                if (offer.PlayerName.IndexOf("<") != -1)
                {
                    int nameIndex = offer.PlayerName.IndexOf(">");

                    if (nameIndex == -1)
                    {
                        continue;
                    }

                    offer.PlayerName = offer.PlayerName.Substring(nameIndex + 2);
                }

                // Item name
                int itemNameStartIndex = line.IndexOf(ITEM_NAME_START_WORD);

                if (itemNameStartIndex == -1)
                {
                    continue;
                }

                itemNameStartIndex += ITEM_NAME_START_WORD.Length;

                int itemNameEndIndex = line.IndexOf(ITEM_NAME_END_WORD, itemNameStartIndex);

                bool alternateItemNameEndWord = false;

                if (itemNameEndIndex == -1)
                {
                    itemNameEndIndex         = line.IndexOf(ITEM_NAME_ALTERNATE_END_WORD, itemNameStartIndex);
                    alternateItemNameEndWord = true;

                    if (itemNameEndIndex == -1)
                    {
                        continue;
                    }
                }

                offer.ItemName = line.Substring(itemNameStartIndex, itemNameEndIndex - itemNameStartIndex);

                // Price
                int priceStartIndex = itemNameEndIndex + (alternateItemNameEndWord ? ITEM_NAME_ALTERNATE_END_WORD : ITEM_NAME_END_WORD).Length;
                int priceEndIndex   = line.IndexOf(" ", priceStartIndex);

                if (priceEndIndex == -1)
                {
                    continue;
                }
                var value = line.Substring(priceStartIndex, priceEndIndex - priceStartIndex)
                            .Trim()
                            .Replace(".", ",");

                offer.Price = Convert.ToDouble(value);

                // Currency
                int currencyStartIndex = priceEndIndex + 1;
                int currencyEndIndex   = line.IndexOf(CURRENCY_END_WORD, currencyStartIndex);

                if (currencyEndIndex == -1)
                {
                    continue;
                }

                offer.Currency          = line.Substring(currencyStartIndex, currencyEndIndex - currencyStartIndex);
                offer.CurrencyImageLink = AppService.Instance.GetCurrencyImageLink(offer.Currency);

                // League
                int leagueStartIndex = currencyEndIndex + CURRENCY_END_WORD.Length;
                int leagueEndIndex   = line.IndexOf(" ", leagueStartIndex);

                if (leagueEndIndex == -1)
                {
                    offer.League   = line.Substring(leagueStartIndex);
                    leagueEndIndex = leagueStartIndex + offer.League.Length;
                }
                else
                {
                    offer.League = line.Substring(leagueStartIndex, leagueEndIndex - leagueStartIndex);
                }

                offer.League = Regex.Replace(offer.League, @"[0-9\.]", "");

                var config = AppService.Instance.GetConfig();
                if (config.AutoWhisperOutOfLeague && offer.League != config.CurrentLeague)
                {
                    AppService.Instance.SendChatMessage($"@{offer.PlayerName} {AppService.Instance.ReplaceVars(config.OutOfLeagueWhisper, offer)}");
                    return(null);
                }

                // Item location
                int itemTabStartIndex = line.IndexOf("(stash tab \"", leagueEndIndex);
                int topEndIndex       = -1;

                if (itemTabStartIndex != -1)
                {
                    itemTabStartIndex += "(stash tab \"".Length;
                    int itemTabEndIndex = line.IndexOf("\"; position: left ", itemTabStartIndex);

                    if (itemTabEndIndex != -1)
                    {
                        offer.StashTab = line.Substring(itemTabStartIndex, itemTabEndIndex - itemTabStartIndex);

                        int leftStartIndex = itemTabEndIndex + "\"; position: left ".Length;
                        int leftEndIndex   = line.IndexOf(", top ", leftStartIndex);

                        if (leftEndIndex != -1)
                        {
                            int x = int.Parse(line.Substring(leftStartIndex, leftEndIndex - leftStartIndex));

                            int topStartIndex = leftEndIndex + ", top ".Length;
                            topEndIndex = line.IndexOf(")", topStartIndex);

                            if (topEndIndex != -1)
                            {
                                int y = int.Parse(line.Substring(topStartIndex, topEndIndex - topStartIndex));
                                ++topEndIndex;
                                offer.Position = new System.Drawing.Point(x, y);
                            }
                        }
                    }
                }

                // Aditionnal notes
                if ((topEndIndex != -1 && topEndIndex + 1 < line.Length) || (leagueEndIndex < line.Length))
                {
                    offer.Notes = line.Substring(topEndIndex == -1 ? leagueEndIndex : topEndIndex);
                }

                offer.Id = NextId();

                evt       = offer;
                processed = true;
            }

            if (!processed)
            {
                log.Trace("Line wasn't an offer, trying to parse has other events");
                var line = aline.ToLower();

                if (line.IndexOf(TRADE_ACCEPTED_MSG) != -1)
                {
                    evt = new ChatEvent()
                    {
                        EvenType = Enums.ChatEventEnum.TradeAccepted
                    };
                }
                else if (line.IndexOf(TRADE_CANCELLED_MSG) != -1)
                {
                    evt = new ChatEvent()
                    {
                        EvenType = Enums.ChatEventEnum.TradeCancelled
                    };
                }
                else if (line.IndexOf(PLAYER_JOINED_MSG) != -1)
                {
                    var startIndex = aline.IndexOf("] : ");
                    var endIndex   = aline.IndexOf(PLAYER_JOINED_MSG);

                    if (startIndex != -1 && endIndex != -1)
                    {
                        startIndex += "] : ".Length;
                        evt         = new JoinEvent(aline.Substring(startIndex, endIndex - startIndex));
                    }
                }
                else if (line.ToLower().IndexOf(AREA_JOINED) != -1)
                {
                    string name = aline.Substring(line.IndexOf(AREA_JOINED) + AREA_JOINED.Length);
                    name = name.Substring(0, name.Length - 1);
                    name = Regex.Replace(name, " Level [0-9]+", "");
                    string type = name.ToLower().IndexOf("hideout") != -1 ? "Hideout" : "Unknown";

                    if (Areas.ContainsKey(name))
                    {
                        name = Areas[name].Name;
                        type = Areas[name].Type;
                    }

                    evt = new AreaChangedEvent()
                    {
                        EvenType = ChatEventEnum.AreaJoined,
                        Name     = name,
                        Type     = type
                    };
                }
            }

            return(evt);
        }
Exemple #32
0
 public override void HandleJoin(JoinEvent ev)
 {
     Bind(ev.User);
 }
Exemple #33
0
 protected override async Task OnJoinAsync(JoinEvent ev)
 {
     await messagingClient.ReplyMessageAsync(ev.ReplyToken, $"Thank you for letting me join your {ev.Source.Type.ToString().ToLower()}!");
 }
Exemple #34
0
 static void OnJoin(JoinEvent e)
 {
     Chat.Of(bot).PrivateMessage(e.Player, e.Username);
 }