Connect() public method

public Connect ( ) : void
return void
Beispiel #1
0
        public Gateway()
        {
            PusherClient.Pusher pusher = new PusherClient.Pusher("7b4abaf489e799ceeceb");

            Channel alarmChannel = pusher.Subscribe("alarms");
            Channel cmdChannel   = pusher.Subscribe("commands");

            alarmChannel.Bind("ack", (dynamic data) =>
            {
                try
                {
                    EventAcknowled(data);
                }
                catch (Exception ex)
                {
                    var e = ex;
                }
            });

            cmdChannel.Bind("action", (dynamic data) =>
            {
                try
                {
                    EventCommand(data);
                }
                catch (Exception ex)
                {
                    var e = ex;
                }
            });

            pusher.Connect();
        }
        private static void InitPusher()
        {
            _pusher = new Pusher("7899dd5cb232af88083d", new PusherOptions(){
                Authorizer = new HttpAuthorizer("http://localhost:8888/auth/" + HttpUtility.UrlEncode(_name))
            });
            _pusher.ConnectionStateChanged += _pusher_ConnectionStateChanged;
            _pusher.Error += _pusher_Error;

            // Setup private channel
            _chatChannel = _pusher.Subscribe("private-channel");
            _chatChannel.Subscribed += _chatChannel_Subscribed;

            // Inline binding!
            _chatChannel.Bind("client-my-event", (dynamic data) =>
            {
                Console.WriteLine("[" + data.name + "] " + data.message);
            });

            // Setup presence channel
            _presenceChannel = (PresenceChannel)_pusher.Subscribe("presence-channel");
            _presenceChannel.Subscribed += _presenceChannel_Subscribed;
            _presenceChannel.MemberAdded += _presenceChannel_MemberAdded;
            _presenceChannel.MemberRemoved += _presenceChannel_MemberRemoved;

            _pusher.Connect();
        }
Beispiel #3
0
        public Gateway()
        {
            PusherClient.Pusher pusher = new PusherClient.Pusher("7b4abaf489e799ceeceb");

            Channel alarmChannel = pusher.Subscribe("alarms");
            Channel cmdChannel = pusher.Subscribe("commands");

            alarmChannel.Bind("ack", (dynamic data) =>
            {
                try
                {
                    EventAcknowled(data);
                }
                catch (Exception ex)
                {
                    var e = ex;
                }

            });

            cmdChannel.Bind("action", (dynamic data) =>
            {
                try
                {
                    EventCommand(data);
                }
                catch (Exception ex)
                {
                    var e = ex;
                }

            });

            pusher.Connect();
        }
 private static void InitPusher()
 {
     _pusher = new Pusher("7899dd5cb232af88083d", new PusherOptions(){
         Authorizer = new HttpAuthorizer("http://localhost:8888/auth/" + HttpUtility.UrlEncode(_name))
     });
     _pusher.Connected += pusher_Connected;
     _pusher.ConnectionStateChanged += _pusher_ConnectionStateChanged;
     _pusher.Connect();
 }
 private static void InitPusher()
 {
     _pusher = new Pusher("527784eba833ff169524", new PusherOptions() {
         Authorizer = new HttpAuthorizer("http://localhost:8888/auth/" + HttpUtility.UrlEncode(_name))
     });
     _pusher.Connected += pusher_Connected;
     _pusher.ConnectionStateChanged += _pusher_ConnectionStateChanged;
     _pusher.Connect();
 }
Beispiel #6
0
 void Start()
 {
     PusherSettings.Verbose     = true;
     PusherSettings.AppKey      = "3a375f8a13577d092e5897e6ce3a02";
     PusherSettings.HttpAuthUrl = "http://test.flave.world:8080";
     pusherClient            = new PusherClient.Pusher();
     pusherClient.Connected += HandleConnected;
     pusherClient.ConnectionStateChanged += HandleConnectionStateChanged;
     pusherClient.Connect();
 }
    // Initialize
    void Start()
    {
        // TODO: Replace these with your app values
        PusherSettings.Verbose = true;
        PusherSettings.AppKey = "";
        PusherSettings.HttpAuthUrl = "http://richmond.kingdoms.metamoki.com/bin/pusher-auth.php";

        pusherClient = new PusherClient.Pusher();
        pusherClient.Connected += HandleConnected;
        pusherClient.ConnectionStateChanged += HandleConnectionStateChanged;
        pusherClient.Connect();
    }
Beispiel #8
0
    // Initialize
    void Start()
    {
        // TODO: Replace these with your app values
        PusherSettings.Verbose     = true;
        PusherSettings.AppKey      = "";
        PusherSettings.HttpAuthUrl = "http://richmond.kingdoms.metamoki.com/bin/pusher-auth.php";

        pusherClient            = new PusherClient.Pusher();
        pusherClient.Connected += HandleConnected;
        pusherClient.ConnectionStateChanged += HandleConnectionStateChanged;
        pusherClient.Connect();
    }
    // Initialize
    void Start()
    {
        // TODO: Replace these with your app values
        PusherSettings.Verbose     = true;
        PusherSettings.AppKey      = this.pusherAppKey;
        PusherSettings.Host        = "ws-" + this.pusherCluster + ".pusher.com";
        PusherSettings.HttpAuthUrl = this.pusherHttpAuthUrl;

        pusherClient            = new PusherClient.Pusher();
        pusherClient.Connected += HandleConnected;
        pusherClient.ConnectionStateChanged += HandleConnectionStateChanged;
        pusherClient.Connect();
    }
Beispiel #10
0
    public void StartPusher(string url, string channel)
    {
        this.channel = channel;

        PusherSettings.Verbose     = true;
        PusherSettings.AppKey      = "3a375f8a13577d092e5897e6ce3a02";
        PusherSettings.HttpAuthUrl = url;
        pusherClient            = new PusherClient.Pusher();
        pusherClient.Connected += HandleConnected;
        pusherClient.ConnectionStateChanged += HandleConnectionStateChanged;
        pusherClient.Connect();

        StartCoroutine(testConnection());
    }
Beispiel #11
0
        public void Start()
        {
            var pusher = new PusherClient.Pusher("de504dc5763aeef9ff52");

            pusher.ConnectionStateChanged += _pusher_ConnectionStateChanged;
            pusher.Error += _pusher_Error;
            foreach (var pair in _currencyPairs)
            {
                // Setup private channel
                // RegisterTradeChannel(pusher, pair);
                RegisterOrderBookChannel(pusher, pair);
            }
            pusher.Connect();
        }
        void HandleSteamMessage (CallbackMsg msg)
        {
            log.Debug(msg.ToString());

            #region Login
            msg.Handle<SteamClient.ConnectedCallback> (callback =>
            {
                log.Debug ("Connection Callback: " + callback.Result);

                if (callback.Result == EResult.OK)
                {
                    UserLogOn();
                }
                else
                {
                    log.Error ("Failed to connect to Steam Community, trying again...");
                    SteamClient.Connect ();
                }

            });

            msg.Handle<SteamUser.LoggedOnCallback> (callback =>
            {
                log.Debug ("Logged On Callback: " + callback.Result);

                if (callback.Result == EResult.OK)
                {
                    MyLoginKey = callback.WebAPIUserNonce;
                }
                else
                {
                    log.Error ("Login Error: " + callback.Result);
                }

                if (callback.Result == EResult.AccountLogonDenied)
                {
                    log.Interface ("This account is SteamGuard enabled. Enter the code via the `auth' command.");

                    // try to get the steamguard auth code from the event callback
                    var eva = new SteamGuardRequiredEventArgs();
                    FireOnSteamGuardRequired(eva);
                    if (!String.IsNullOrEmpty(eva.SteamGuard))
                        logOnDetails.AuthCode = eva.SteamGuard;
                    else
                        logOnDetails.AuthCode = Console.ReadLine();
                }

                if (callback.Result == EResult.InvalidLoginAuthCode)
                {
                    log.Interface("The given SteamGuard code was invalid. Try again using the `auth' command.");
                    logOnDetails.AuthCode = Console.ReadLine();
                }
            });

            msg.Handle<SteamUser.LoginKeyCallback> (callback =>
            {
                while (true)
                {
                    bool authd = SteamWeb.Authenticate(callback, SteamClient, out sessionId, out token, MyLoginKey);

                    if (authd)
                    {
                        botCookies = new CookieContainer();
                        botCookies.SetCookies(new Uri("http://steamcommunity.com"), string.Format("steamLogin={0}", token));
                        botCookies.SetCookies(new Uri("http://steamcommunity.com"), string.Format("sessionid={0};", sessionId));
                        GenericInventory.SetCookie(botCookies, SteamUser.SteamID);
                        log.Success ("User Authenticated!");
                        BotSteamIds.Add(SteamUser.SteamID);

                        tradeManager = new TradeManager(apiKey, sessionId, token);
                        tradeManager.SetTradeTimeLimits(MaximumTradeTime, MaximiumActionGap, TradePollingInterval);
                        tradeManager.OnTimeout += OnTradeTimeout;
                        break;
                    }
                    else
                    {
                        log.Warn ("Authentication failed, retrying in 2s...");
                        Thread.Sleep (2000);
                    }
                }

                SteamFriends.SetPersonaName (DisplayNamePrefix+DisplayName);
                SteamFriends.SetPersonaState (EPersonaState.Online);

                log.Success ("Steam Bot Logged In Completely!");

                IsLoggedIn = true;

                botCookies = new CookieContainer();                
                botCookies.SetCookies(new Uri("http://steamcommunity.com"), string.Format("steamLogin={0}", token));
                botCookies.SetCookies(new Uri("http://steamcommunity.com"), string.Format("sessionid={0}", sessionId));
                GenericInventory.SetCookie(botCookies, SteamUser.SteamID);

                Pusher = new Pusher("51a9410427d703c5a743");
                Pusher.Connected += Pusher_Connected;
                Pusher.Connect();

                GetUserHandler(SteamClient.SteamID).OnLoginCompleted();
            });

            // handle a special JobCallback differently than the others
            if (msg.IsType<SteamClient.JobCallback<SteamUser.UpdateMachineAuthCallback>>())
            {
                msg.Handle<SteamClient.JobCallback<SteamUser.UpdateMachineAuthCallback>>(
                    jobCallback => OnUpdateMachineAuthCallback(jobCallback.Callback, jobCallback.JobID)
                );
            }
            #endregion

            #region Friends
            msg.Handle<SteamFriends.FriendsListCallback>(callback =>
            {
                foreach (SteamFriends.FriendsListCallback.Friend friend in callback.FriendList)
                {
                    if (friend.SteamID.AccountType == EAccountType.Clan)
                    {
                        if (!groups.Contains(friend.SteamID))
                        {
                            groups.Add(friend.SteamID);
                            if (friend.Relationship == EFriendRelationship.RequestRecipient)
                            {
                                if (GetUserHandler(friend.SteamID).OnGroupAdd())
                                {
                                    AcceptGroupInvite(friend.SteamID);
                                }
                                else
                                {
                                    DeclineGroupInvite(friend.SteamID);
                                }
                            }
                        }
                        else
                        {
                            if (friend.Relationship == EFriendRelationship.None)
                            {
                                groups.Remove(friend.SteamID);
                            }
                        }
                    }
                    else if (friend.SteamID.AccountType != EAccountType.Clan)
                    {
                    if (!friends.Contains(friend.SteamID))
                    {
                        friends.Add(friend.SteamID);
                        if (friend.Relationship == EFriendRelationship.RequestRecipient &&
                            GetUserHandler(friend.SteamID).OnFriendAdd())
                        {
                            SteamFriends.AddFriend(friend.SteamID);
                        }
                    }
                    else
                    {
                        if (friend.Relationship == EFriendRelationship.None)
                        {
                            friends.Remove(friend.SteamID);
                            GetUserHandler(friend.SteamID).OnFriendRemove();
                        }
                    }
                }
                }
            });


            msg.Handle<SteamFriends.FriendMsgCallback> (callback =>
            {
                EChatEntryType type = callback.EntryType;

                if (callback.EntryType == EChatEntryType.ChatMsg)
                {
                    log.Info (String.Format ("Chat Message from {0}: {1}",
                                         SteamFriends.GetFriendPersonaName (callback.Sender),
                                         callback.Message
                                         ));
                    GetUserHandler(callback.Sender).OnMessage(callback.Message, type);
                }
            });
            #endregion

            #region Group Chat
            msg.Handle<SteamFriends.ChatMsgCallback>(callback =>
            {
                GetUserHandler(callback.ChatterID).OnChatRoomMessage(callback.ChatRoomID, callback.ChatterID, callback.Message);
            });
            #endregion

            #region Trading
            msg.Handle<SteamTrading.SessionStartCallback> (callback =>
            {
                bool started = HandleTradeSessionStart (callback.OtherClient);

                if (!started)
                    log.Error ("Could not start the trade session.");
                else
                    log.Debug ("SteamTrading.SessionStartCallback handled successfully. Trade Opened.");
            });

            msg.Handle<SteamTrading.TradeProposedCallback> (callback =>
            {
                try
                {
                    tradeManager.InitializeTrade(SteamUser.SteamID, callback.OtherClient);
                }
                catch (WebException we)
                {                 
                    SteamFriends.SendChatMessage(callback.OtherClient,
                             EChatEntryType.ChatMsg,
                             "Trade error: " + we.Message);

                    SteamTrade.RespondToTrade(callback.TradeID, false);
                    return;
                }
                catch (Exception)
                {
                    SteamFriends.SendChatMessage(callback.OtherClient,
                             EChatEntryType.ChatMsg,
                             "Trade declined. Could not correctly fetch your backpack.");

                    SteamTrade.RespondToTrade(callback.TradeID, false);
                    return;
                }

                if (CurrentTrade == null && GetUserHandler (callback.OtherClient).OnTradeRequest ())
                    SteamTrade.RespondToTrade (callback.TradeID, true);
                else
                    SteamTrade.RespondToTrade (callback.TradeID, false);
            });

            msg.Handle<SteamTrading.TradeResultCallback> (callback =>
            {
                if (callback.Response == EEconTradeResponse.Accepted)
                {
                    log.Debug ("Trade Status: " + callback.Response);
                    log.Info ("Trade Accepted!");
                    GetUserHandler(callback.OtherClient).OnTradeRequestReply(true, callback.Response.ToString());
                }
                else
                {
                    log.Warn ("Trade failed: " + callback.Response);
                    CloseTrade ();
                    GetUserHandler(callback.OtherClient).OnTradeRequestReply(false, callback.Response.ToString());
                }

            });
            #endregion

            #region Disconnect
            msg.Handle<SteamUser.LoggedOffCallback> (callback =>
            {
                IsLoggedIn = false;
                log.Warn ("Logged Off: " + callback.Result);
            });

            msg.Handle<SteamClient.DisconnectedCallback> (callback =>
            {
                IsLoggedIn = false;
                CloseTrade ();
                log.Warn ("Disconnected from Steam Network!");
                SteamClient.Connect ();
            });
            #endregion
        }
 private void InitPusher()
 {
     var proxyEndPoint = new IPEndPoint(IPAddress.Parse("192.168.1.87"), 8888);
     _pusher = new Pusher(PUSHER_APP_KEY, new PusherOptions()
     {
         Authorizer = new HttpAuthorizer(PUSHER_AUTH_HOST + "/auth/" + HttpUtility.UrlEncode(_name), proxyEndPoint),
         ProxyEndPoint = proxyEndPoint,
     });
     _pusher.Connected += pusher_Connected;
     _pusher.ConnectionStateChanged += _pusher_ConnectionStateChanged;
     _pusher.Connect();
 }
 public unsafe void Connect()
 {
     pusherClient.Connect();
 }
 private void InitPusher()
 {
     _pusher = new Pusher(PUSHER_APP_KEY, new PusherOptions()
     {
         Authorizer = new HttpAuthorizer(PUSHER_AUTH_HOST + "/auth/" + HttpUtility.UrlEncode(_name))
     });
     _pusher.Connected += pusher_Connected;
     _pusher.ConnectionStateChanged += _pusher_ConnectionStateChanged;
     _pusher.Connect();
 }