當前位置: 首頁>>代碼示例>>C#>>正文


C# Message.GenerateId方法代碼示例

本文整理匯總了C#中agsXMPP.protocol.client.Message.GenerateId方法的典型用法代碼示例。如果您正苦於以下問題:C# Message.GenerateId方法的具體用法?C# Message.GenerateId怎麽用?C# Message.GenerateId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在agsXMPP.protocol.client.Message的用法示例。


在下文中一共展示了Message.GenerateId方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: BeginGetGameList

        public void BeginGetGameList() 
        {
			var m = new Message(new Jid("[email protected]" + Host), MessageType.normal, "", "gamelist");
            m.GenerateId();
            Xmpp.Send(m);
        }
開發者ID:Himorask,項目名稱:OCTGN,代碼行數:6,代碼來源:Client.cs

示例2: BeginHostGame

 public Guid BeginHostGame(Guid gameid, Version gameVersion, string gamename,
     string gameIconUrl, string password, string actualgamename, Version sasVersion, bool specators)
 {
     var hgr = new HostGameRequest(gameid, gameVersion, gamename, actualgamename, gameIconUrl, password ?? "", sasVersion, specators);
     Log.InfoFormat("BeginHostGame {0}", hgr);
     var m = new Message(new Jid(AppConfig.Instance.GameServUsername, AppConfig.Instance.ServerPath, null), this.Xmpp.MyJID, MessageType.normal, "", "hostgame");
     m.GenerateId();
     m.AddChild(hgr);
     this.Xmpp.Send(m);
     return hgr.RequestId;
 }
開發者ID:rexperalta,項目名稱:OCTGN,代碼行數:11,代碼來源:MatchmakingBot.cs

示例3: BeginHostGame

        public void BeginHostGame(Game game, string gamename)
        {
            var data = String.Format("{0},:,{1},:,{2}",game.Id.ToString(),game.Version.ToString(),gamename);
			var m = new Message(new Jid("[email protected]" + Host), Me.User, MessageType.normal, data, "hostgame");
            m.GenerateId();
            Xmpp.Send(m);
        }
開發者ID:Himorask,項目名稱:OCTGN,代碼行數:7,代碼來源:Client.cs

示例4: XmppOnOnMessage

 private static void XmppOnOnMessage(object sender , Message msg)
 {
     switch(msg.Type)
     {
         case MessageType.normal:
             if(msg.Subject == "hostgame")
             {
                 var data = msg.Body.Split(new string[1]{",:,"},StringSplitOptions.RemoveEmptyEntries);
                 if (data.Length != 3) return;
                 var guid = Guid.Empty;
                 Version ver = null;
                 if (String.IsNullOrWhiteSpace(data[2])) return;
                 var gameName = data[2];
                 if(Guid.TryParse(data[0] , out guid) && Version.TryParse(data[1] , out ver))
                 {
                     var port = Gaming.HostGame(guid , ver , gameName , "" , new NewUser(msg.From));
                     if (port == -1) return;
                     var m = new Message(msg.From , msg.To , MessageType.normal , port.ToString() , "gameready");
                     m.GenerateId();
                     Xmpp.Send(m);
                     var gameMessage = String.Format(" {0} is hosting a game called '{1}'" ,msg.From.User,gameName);
                     m = new Message(new Jid("[email protected]nference." + ServerPath), msg.To, MessageType.groupchat, gameMessage);
                     //Xmpp.Send(m);
                     //RefreshLists();
                 }
             }
             else if(msg.Subject == "gamelist")
             {
                 //Trace.WriteLine("[Bot]Request GameList: " + msg.From.User);
                 var list = Gaming.GetLobbyList().Where(x=>x.GameStatus == EHostedGame.StartedHosting);
                 var m = new Message(msg.From , MessageType.normal , "" , "gamelist");
                 m.GenerateId();
                 foreach (var a in list)
                 {
                     m.AddChild(a);
                 }
                 Xmpp.Send(m);
             }
             else if(msg.Subject == "gamestarted")
             {
                 int port = -1;
                 if(Int32.TryParse(msg.Body,out port))
                     Gaming.StartGame(port);
                 //RefreshLists();
             }
             break;
         case MessageType.error:
             break;
         case MessageType.chat:
             break;
         case MessageType.groupchat:
             break;
         case MessageType.headline:
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
開發者ID:Gondulf,項目名稱:OCTGN,代碼行數:58,代碼來源:GameBot.cs

示例5: XmppOnOnMessage

        private void XmppOnOnMessage(object sender , Message msg)
        {
            try
            {
                switch (msg.Type)
                {
                    case MessageType.normal:
                        if (msg.Subject == "hostgame")
                        {

                            if (msg.HasChildElements == false)
                            {
                                // F it, someone screwed up this year.
                                return;
                            }

                            if (msg.ChildNodes.OfType<HostGameRequest>().Any() == false)
                            {
                                // Again, what the fuuuuu
                                return;
                            }

                            var req = msg.ChildNodes.OfType<HostGameRequest>().First();

                            Log.InfoFormat("Host game from {0}", msg.From);
                            while (SasUpdater.Instance.IsUpdating)
                            {
                                Thread.Sleep(100);
                            }
                            var id = GameManager.Instance.HostGame(req, new User(msg.From));

                            if(id != Guid.Empty)
                                userRequests.Add("hostrequest_" + id, id, DateTimeOffset.UtcNow.AddSeconds(30));
                        }
                        else if (msg.Subject == "gamelist")
                        {
                            // If someone tried to refresh their game list too soon, f them
                            if (userRequests.Contains("refreshrequest_" + msg.From.User.ToLower()))
                                return;
                            // Mark the user as already requested a list for the next 15 seconds
                            userRequests.Add("refreshrequest_" + msg.From.User.ToLower(), 1, DateTimeOffset.UtcNow.AddSeconds(15));
                            var list = GameManager.Instance.Games;
                            var m = new Message(msg.From, MessageType.normal, "", "gamelist");
                            m.GenerateId();
                            foreach (var a in list)
                            {
                                m.AddChild(a);
                            }
                            Xmpp.Send(m);
                        }
                        else if (msg.Subject == "killgame")
                        {
                            var items = msg.Body.Split(new[]{"#:999:#"}, StringSplitOptions.RemoveEmptyEntries);
                            if (items.Length != 2) return;
                            var client = new ApiClient();
                            var res = client.Login(msg.From.User, items[1]);
                            if (res == LoginResult.Ok)
                            {
                                var id = Guid.Parse(items[0]);
                                GameManager.Instance.KillGame(id);
                            }
                            throw new Exception("Error verifying user " + res);
                        }
                        break;
                    case MessageType.error:
                        break;
                    case MessageType.chat:
                        if (!msg.From.User.Equals("d0c", StringComparison.InvariantCultureIgnoreCase)) return;
                        // Keep this around in case we want to add commands at some point, we'll have an idea on how to write the code
                        //if (msg.Body.Equals("pause"))
                        //{
                        //    _isPaused = true;
                        //    Log.Warn(":::::: PAUSED ::::::");
                        //    var m = new Message(msg.From, MessageType.chat, "Paused");
                        //    m.GenerateId();
                        //    Xmpp.Send(m);
                        //}
                        break;
                }

            }
            catch (Exception e)
            {
                Log.Error("[Bot]XmppOnOnMessage Error",e);
            }
        }
開發者ID:rerbes,項目名稱:OCTGN,代碼行數:86,代碼來源:GameBot.cs

示例6: SendGameReady

 public void SendGameReady(HostedGameData game)
 {
     var m = new Message(game.Username + "@of.octgn.net", MessageType.normal, "", "gameready");
     m.GenerateId();
     m.AddChild(game);
     Xmpp.Send(m);
 }
開發者ID:rerbes,項目名稱:OCTGN,代碼行數:7,代碼來源:GameBot.cs

示例7: OnGameHostResponse

        public void OnGameHostResponse(HostedGameData data)
        {
            if (_waitingRequestId != data.Id)
                return;
            lock (_users)
            {
				Log.InfoFormat("[{0}] Got Hosted Game Data {1}",this,data);
                if (State != MatchmakingQueueState.WaitingForHostedGame)
                {
                    // Actually this can happen if someone cancels out of the queue
                    //Log.Fatal("Timeed out before hosted game could be returned. Need to increase timeout.");
                    //this._hostGameTimeout.When = new TimeSpan(0,0,(int)_hostGameTimeout.When.TotalSeconds + 5);
                    return;
                }
                // Send all users a message telling them the info they need to connect to game server
                // Kick all the users from the queue.
                var message = new Message(new Jid("[email protected]"), MessageType.normal, "", "gameready");
                message.ChildNodes.Add(data);
				Log.InfoFormat("[{0}] Sending users game data",this);
                foreach (var u in _users.Where(x => x.IsInReadyQueue).ToArray())
                {
                    message.To = u.JidUser;
                    message.GenerateId();
                    this.Bot.Xmpp.Send(message);
                    _users.Remove(u);
                }
                // set time to game
                AverageTime.Cycle();
                State = MatchmakingQueueState.WaitingForUsers;
            }
        }
開發者ID:rexperalta,項目名稱:OCTGN,代碼行數:31,代碼來源:MatchmakingQueue.cs

示例8: XmppOnOnMessage

 private static void XmppOnOnMessage(object sender , Message msg)
 {
     switch(msg.Type)
     {
         case MessageType.normal:
             if(msg.Subject == "hostgame")
             {
                 if (isPaused)
                 {
                     messageQueue.Enqueue(msg);
                     return;
                 }
                 var data = msg.Body.Split(new string[1]{",:,"},StringSplitOptions.None);
                 if (data.Length != 4) return;
                 var guid = Guid.Empty;
                 Version ver = null;
                 if (String.IsNullOrWhiteSpace(data[2])) return;
                 var gameName = data[2];
                 var password = data[3];
                 if(Guid.TryParse(data[0] , out guid) && Version.TryParse(data[1] , out ver))
                 {
                     var port = Gaming.HostGame(guid , ver , gameName , password , new Lobby.User(msg.From));
                     if (port == -1) return;
                     var m = new Message(msg.From , msg.To , MessageType.normal , port.ToString() , "gameready");
                     m.GenerateId();
                     Xmpp.Send(m);
                 }
             }
             else if(msg.Subject == "gamelist")
             {
                 if (isPaused)
                 {
                     messageQueue.Enqueue(msg);
                     return;
                 }
                 var list = Gaming.GetLobbyList().Where(x=>x.GameStatus == EHostedGame.StartedHosting);
                 var m = new Message(msg.From , MessageType.normal , "" , "gamelist");
                 m.GenerateId();
                 foreach (var a in list)
                 {
                     m.AddChild(a);
                 }
                 Xmpp.Send(m);
             }
             else if (msg.Subject == "gamestarted")
             {
                 if (isPaused)
                 {
                     messageQueue.Enqueue(msg);
                     return;
                 }
                 int port = -1;
                 if (Int32.TryParse(msg.Body, out port)) Gaming.StartGame(port);
             }
             break;
         case MessageType.error:
             break;
         case MessageType.chat:
                 if (!msg.From.User.Equals("d0c", StringComparison.InvariantCultureIgnoreCase)) return;
                 if (msg.Body.Equals("pause"))
                 {
                     isPaused = true;
                     Console.WriteLine(":::::: PAUSED ::::::");
                     var m = new Message(msg.From, MessageType.chat, "Paused");
                     m.GenerateId();
                     Xmpp.Send(m);
                 }
                 else if (msg.Body.Equals("unpause"))
                 {
                     isPaused = false;
                     Console.WriteLine("Unpausing...");
                     var m = new Message(msg.From, MessageType.chat, "Unpausing");
                     m.GenerateId();
                     Xmpp.Send(m);
                     while (messageQueue.Count > 0)
                     {
                         XmppOnOnMessage(null,messageQueue.Dequeue());
                     }
                     Console.WriteLine(":::::: UNPAUSED ::::::");
                     var m2 = new Message(msg.From, MessageType.chat, "UnPaused");
                     m2.GenerateId();
                     Xmpp.Send(m2);
                 }
             break;
         case MessageType.groupchat:
             break;
         case MessageType.headline:
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
開發者ID:Kamalisk,項目名稱:OCTGN,代碼行數:92,代碼來源:GameBot.cs


注:本文中的agsXMPP.protocol.client.Message.GenerateId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。