示例#1
0
        private void My_OnLocationChange(Windows.Devices.Geolocation.Geoposition obj)
        {
            var msg = BuddyRunInfo.FromGeoposition(obj, DateTime.UtcNow);

            msg.SourceUserId = eBuddyApp.Services.Azure.MobileService.Instance.UserData.FacebookId;
            msg.DestUserId   = "sid:af7d6ae6d4abbcb585bc46ab45d42c05"; //todo change to real usrid

            RunnersHubProxy.Invoke("SendLocation", msg);
        }
示例#2
0
        internal async Task <bool> ConnectHub()
        {
            RunnersHubConnection =
                new HubConnection(eBuddyApp.Services.Azure.MobileService.Instance.Service.MobileAppUri.AbsoluteUri);
            RunnersHubProxy = RunnersHubConnection.CreateHubProxy("SocialRunsHub");

            if (eBuddyApp.Services.Azure.MobileService.Instance.Service.CurrentUser != null)
            {
                RunnersHubConnection.Headers["x-zumo-auth"] =
                    eBuddyApp.Services.Azure.MobileService.Instance.Service.CurrentUser.MobileServiceAuthenticationToken;
            }
            else
            {
                RunnersHubConnection.Headers["x-zumo-application"] = "";
            }

            await RunnersHubConnection.Start();


            if (RunnersHubConnection.State != ConnectionState.Connected)
            {
                return(false);
            }

            RunnersHubProxy.On <string>("runStart", OnHandShake);

            RunnersHubProxy.On <BuddyRunInfo>("buddyLocationUpdate", OnLocationMessage);

            await RunnersHubProxy.Invoke("Register",
                                         eBuddyApp.Services.Azure.MobileService.Instance.Service.CurrentUser.UserId);

            await RunnersHubProxy.Invoke("HandShake", "shiran6",
                                         eBuddyApp.Services.Azure.MobileService.Instance.Service.CurrentUser.UserId);

            return(true);
        }