Exemplo n.º 1
0
        public void UpdateStatus(APICallback apcCallback, object objCallbackArg, string sMessage)
        {
            Dictionary <string, string> dssParams = new Dictionary <string, string>();

            dssParams["status"] = sMessage;
            DoRequest("statuses/update.json", WebMethod.Post, dssParams, new APIReturn(apcCallback, null, objCallbackArg));
        }
Exemplo n.º 2
0
        public void Retweet(APICallback apcCallback, object objCallbackArg, string sTweetId, bool bTrimUser = false, bool bIncludeEntities = false)
        {
            Dictionary <string, string> dssParams = new Dictionary <string, string>();

            AddParameter(ref dssParams, "trim_user", bTrimUser);
            AddParameter(ref dssParams, "include_entities", bIncludeEntities);

            DoRequest("statuses/retweet/" + sTweetId + ".json", WebMethod.Post, dssParams, new APIReturn(apcCallback, null, objCallbackArg));
        }
Exemplo n.º 3
0
        public void DestroyFavorite(APICallback apcCallback, object objCallbackArg, string sStatusId, bool bIncludeEntities = false)
        {
            Dictionary <string, string> dssParams = new Dictionary <string, string>();

            AddParameter(ref dssParams, "id", sStatusId);
            AddParameter(ref dssParams, "include_entities", bIncludeEntities);

            DoRequest("favorites/destroy/" + sStatusId + ".json", WebMethod.Delete, dssParams, new APIReturn(apcCallback, typeof(Status), objCallbackArg));
        }
Exemplo n.º 4
0
        public void GetMentions(APICallback apcCallback, object objCallbackArg, int iCount = 20, int iPage = 1, int iSinceId = -1,
                                int iMaxId = -1, bool bTrimUser = false, bool bIncludeEntities = false)
        {
            Dictionary <string, string> dssParams = new Dictionary <string, string>();

            AddParameter(ref dssParams, "since_id", iSinceId);
            AddParameter(ref dssParams, "max_id", iMaxId);
            AddParameter(ref dssParams, "count", iCount);
            AddParameter(ref dssParams, "page", iPage);
            AddParameter(ref dssParams, "trim_user", bTrimUser);
            AddParameter(ref dssParams, "include_entities", bIncludeEntities);

            DoRequest("statuses/mentions.json", WebMethod.Get, dssParams, new APIReturn(apcCallback, typeof(UserTimeline), objCallbackArg));
        }
Exemplo n.º 5
0
        public void GetFavorites(APICallback apcCallback, object objCallbackArg, string sUserIdOrScreenName = "", int iPage = 1, bool bIncludeEntities = false)
        {
            Dictionary <string, string> dssParams = new Dictionary <string, string>();

            AddParameter(ref dssParams, "page", iPage);
            AddParameter(ref dssParams, "include_entities", bIncludeEntities);

            if (sUserIdOrScreenName == "")
            {
                DoRequest("favorites.format", WebMethod.Get, dssParams, new APIReturn(apcCallback, typeof(Status), objCallbackArg));
            }
            else
            {
                DoRequest("favorites/" + sUserIdOrScreenName + ".json", WebMethod.Get, dssParams, new APIReturn(apcCallback, typeof(Status), objCallbackArg));
            }
        }
Exemplo n.º 6
0
    IEnumerator SendLocation(string url)
    {
        if (Application.internetReachability == NetworkReachability.NotReachable)
            yield break;

        WWW www = new WWW(url);
        yield return www;

        Debug.Log(www.text);

        if (www.error != null)
            _currCallback(new APIEvent(false, www.error));
        else
            _currCallback(new APIEvent(true, www.text));

        _currCallback = null;
    }
Exemplo n.º 7
0
        public void GetUserTimeline(APICallback apcCallback, object objCallbackArg, string sScreenName = null, int iPage = 1, int iCount = 20, int iUserId = -1,
                                    int iMaxId            = -1, bool bTrimUser = false, bool bIncludeRts = true,
                                    bool bIncludeEntities = false)
        {
            Dictionary <string, string> dssParams = new Dictionary <string, string>();

            AddParameter(ref dssParams, "screen_name", sScreenName);
            AddParameter(ref dssParams, "page", iPage);
            AddParameter(ref dssParams, "count", iCount);
            AddParameter(ref dssParams, "user_id", iUserId);
            AddParameter(ref dssParams, "max_id", iMaxId);
            AddParameter(ref dssParams, "trim_user", bTrimUser);
            AddParameter(ref dssParams, "include_rts", bIncludeRts);
            AddParameter(ref dssParams, "include_entities", bIncludeEntities);

            DoRequest("statuses/user_timeline.json", WebMethod.Get, dssParams, new APIReturn(apcCallback, typeof(UserTimeline), objCallbackArg));
        }
Exemplo n.º 8
0
    public void Call(string method, APICallback callback, params object[] args)
    {
        if(_currCallback == null)
        {
            _currCallback = callback;

            string url = "http://ggjspyheart2.cloudapp.net/GameService.svc/" + method;

            foreach(object obj in args)
                url += ("/" + obj.ToString());

            Debug.Log (url);
            StartCoroutine(SendLocation(url));
        }
        else
            throw new Exception("NOPE!");
    }
Exemplo n.º 9
0
        public void LookupUser(APICallback apcCallback, object objCallbackArg, List <string> lsScreenNames = null, List <string> lsUserIds = null, bool bIncludeEntities = false)
        {
            Dictionary <string, string> dssParams = new Dictionary <string, string>();

            if (lsScreenNames != null)
            {
                AddParameter(ref dssParams, "screen_name", lsScreenNames.ToArray());
            }

            if (lsUserIds != null)
            {
                AddParameter(ref dssParams, "user_id", lsUserIds.ToArray());
            }

            AddParameter(ref dssParams, "include_entities", bIncludeEntities);

            DoRequest("users/lookup.json", WebMethod.Post, dssParams, new APIReturn(apcCallback, typeof(List <User>), objCallbackArg));
        }
Exemplo n.º 10
0
        public void Retweet(APICallback apcCallback, object objCallbackArg, string sTweetId, bool bTrimUser = false, bool bIncludeEntities = false)
        {
            Dictionary<string, string> dssParams = new Dictionary<string, string>();

            AddParameter(ref dssParams, "trim_user", bTrimUser);
            AddParameter(ref dssParams, "include_entities", bIncludeEntities);

            DoRequest("statuses/retweet/" + sTweetId + ".json", WebMethod.Post, dssParams, new APIReturn(apcCallback, null, objCallbackArg));
        }
Exemplo n.º 11
0
        public void LookupUser(APICallback apcCallback, object objCallbackArg, List<string> lsScreenNames = null, List<string> lsUserIds = null, bool bIncludeEntities = false)
        {
            Dictionary<string, string> dssParams = new Dictionary<string, string>();

            if (lsScreenNames != null)
                AddParameter(ref dssParams, "screen_name", lsScreenNames.ToArray());

            if (lsUserIds != null)
                AddParameter(ref dssParams, "user_id", lsUserIds.ToArray());

            AddParameter(ref dssParams, "include_entities", bIncludeEntities);

            DoRequest("users/lookup.json", WebMethod.Post, dssParams, new APIReturn(apcCallback, typeof(List<User>), objCallbackArg));
        }
Exemplo n.º 12
0
        public void GetFavorites(APICallback apcCallback, object objCallbackArg, string sUserIdOrScreenName = "", int iPage = 1, bool bIncludeEntities = false)
        {
            Dictionary<string, string> dssParams = new Dictionary<string, string>();

            AddParameter(ref dssParams, "page", iPage);
            AddParameter(ref dssParams, "include_entities", bIncludeEntities);

            if (sUserIdOrScreenName == "")
                DoRequest("favorites.format", WebMethod.Get, dssParams, new APIReturn(apcCallback, typeof(Status), objCallbackArg));
            else
                DoRequest("favorites/" + sUserIdOrScreenName + ".json", WebMethod.Get, dssParams, new APIReturn(apcCallback, typeof(Status), objCallbackArg));
        }
Exemplo n.º 13
0
        public void DestroyFavorite(APICallback apcCallback, object objCallbackArg, string sStatusId, bool bIncludeEntities = false)
        {
            Dictionary<string, string> dssParams = new Dictionary<string, string>();

            AddParameter(ref dssParams, "id", sStatusId);
            AddParameter(ref dssParams, "include_entities", bIncludeEntities);

            DoRequest("favorites/destroy/" + sStatusId + ".json", WebMethod.Delete, dssParams, new APIReturn(apcCallback, typeof(Status), objCallbackArg));
        }
Exemplo n.º 14
0
        public void GetMentions(APICallback apcCallback, object objCallbackArg, int iCount = 20, int iPage = 1, int iSinceId = -1,
                                int iMaxId = -1, bool bTrimUser = false, bool bIncludeEntities = false)
        {
            Dictionary<string, string> dssParams = new Dictionary<string, string>();

            AddParameter(ref dssParams, "since_id", iSinceId);
            AddParameter(ref dssParams, "max_id", iMaxId);
            AddParameter(ref dssParams, "count", iCount);
            AddParameter(ref dssParams, "page", iPage);
            AddParameter(ref dssParams, "trim_user", bTrimUser);
            AddParameter(ref dssParams, "include_entities", bIncludeEntities);

            DoRequest("statuses/mentions.json", WebMethod.Get, dssParams, new APIReturn(apcCallback, typeof(UserTimeline), objCallbackArg));
        }
Exemplo n.º 15
0
        private static void InvokeRpcAsync(RpcHandle handle, Guid iid, byte[] input, APICallback callback)
        {
            Log.Verbose("InvokeRpcAsync on {0}, sending {1} bytes", handle.Handle, input.Length);
            Ptr <MIDL_STUB_DESC> pStub;

            if (!handle.GetPtr(out pStub))
            {
                pStub = handle.CreatePtr(new MIDL_STUB_DESC(
                                             handle, handle.Pin(new RPC_CLIENT_INTERFACE(iid)), RpcApi.TYPE_FORMAT, false));
            }

            int    cbOutput  = 0;
            var    pcbOutput = new Ptr <int>(cbOutput);
            IntPtr result    = IntPtr.Zero;
            IntPtr output    = IntPtr.Zero;
            var    pOutput   = new Ptr <IntPtr>(output);

            using (Ptr <byte[]> pInputBuffer = new Ptr <byte[]>(input))
            {
                AsyncCallback cbRountine = (IntPtr pAsync, IntPtr pContext, RpcAsyncEvent _event) =>
                {
                    RPC_ASYNC_STATE async      = (RPC_ASYNC_STATE)Marshal.PtrToStructure(pAsync, typeof(RPC_ASYNC_STATE));
                    var             myCallback = (APICallback)Marshal.GetDelegateForFunctionPointer(async.UserInfo, typeof(APICallback));

                    RpcError hr = RpcApi.RpcAsyncCompleteCall(pAsync, ref result);
                    if (RpcError.RPC_S_OK == hr)
                    {
                        if (RpcError.RPC_S_OK == (RpcError)result.ToInt32())
                        {
                            ExecuteAsyncResponse response;
                            try
                            {
                                cbOutput = pcbOutput.Data;
                                byte[] _output = new byte[cbOutput];
                                Marshal.Copy(pOutput.Data, _output, 0, cbOutput);

                                response.result   = RpcError.RPC_S_OK;
                                response.response = _output;
                            }
                            catch (Exception e)
                            {
                                response.result   = RpcError.RPC_E_FAIL;
                                response.response = null;
                            }
                            finally
                            {
                                RpcApi.Free(pOutput.Data);
                            }

                            myCallback(response);
                        }
                        else
                        {
                            ExecuteAsyncResponse response;
                            response.result   = (RpcError)result.ToInt32();
                            response.response = null;
                            myCallback(response);
                        }
                    }
                    else
                    {
                        ExecuteAsyncResponse response;
                        response.result   = hr;
                        response.response = null;
                        myCallback(response);
                    }
                };

                var pCallbackRoutine = new FunctionPtr <AsyncCallback>(cbRountine);

                RPC_ASYNC_STATE asyncState   = new RPC_ASYNC_STATE();
                var             _pAsyncState = new Ptr <RPC_ASYNC_STATE>(asyncState);
                RpcApi.RpcAsyncInitializeHandle(_pAsyncState.Handle, Marshal.SizeOf(typeof(RPC_ASYNC_STATE)));
                asyncState.Event                 = _pAsyncState.Data.Event;
                asyncState.Flags                 = _pAsyncState.Data.Flags;
                asyncState.Lock                  = _pAsyncState.Data.Lock;
                asyncState.RuntimeInfo           = _pAsyncState.Data.RuntimeInfo;
                asyncState.Signature             = _pAsyncState.Data.Signature;
                asyncState.Size                  = _pAsyncState.Data.Size;
                asyncState.StubInfo              = _pAsyncState.Data.StubInfo;
                asyncState.NotificationType      = RpcNotificationTypes.RpcNotificationTypeCallback;
                asyncState.u.NotificationRoutine = pCallbackRoutine.Handle;

                var ptrCB = Marshal.GetFunctionPointerForDelegate(callback);
                asyncState.UserInfo = ptrCB;

                var pAsyncState = new Ptr <RPC_ASYNC_STATE>(asyncState);

                if (RpcApi.Is64BitProcess)
                {
                    try
                    {
                        result = RpcApi.NdrAsyncClientCallx64(pStub.Handle, RpcApi.ASYNC_FUNC_FORMAT_PTR.Handle, pAsyncState.Handle, handle.Handle,
                                                              input.Length, pInputBuffer.Handle, out cbOutput, out output);
                    }
                    catch (SEHException ex)
                    {
                        RpcException.Assert(ex.ErrorCode);
                        throw;
                    }
                }
                else
                {
                    using (Ptr <Int32[]> pStack32 = new Ptr <Int32[]>(new Int32[7]))
                    {
                        pStack32.Data[0] = pAsyncState.Handle.ToInt32();
                        pStack32.Data[1] = handle.Handle.ToInt32();
                        pStack32.Data[2] = input.Length;
                        pStack32.Data[3] = pInputBuffer.Handle.ToInt32();
                        pStack32.Data[4] = pcbOutput.Handle.ToInt32();
                        pStack32.Data[5] = pOutput.Handle.ToInt32();
                        pStack32.Data[6] = 0; //reserved

                        try
                        {
                            result = RpcApi.NdrAsyncClientCallx86(pStub.Handle, RpcApi.ASYNC_FUNC_FORMAT_PTR.Handle, pStack32.Handle);
                        }
                        catch (SEHException ex)
                        {
                            Log.Verbose("exception on {0}", ex);
                            RpcException.Assert(ex.ErrorCode);
                            throw;
                        }
                    }
                }

                GC.KeepAlive(pInputBuffer);
            }
            RpcException.Assert(result.ToInt32());
            Log.Verbose("InvokeRpc.InvokeRpc response on {0}", handle.Handle);
        }
Exemplo n.º 16
0
        public void GetUserTimeline(APICallback apcCallback, object objCallbackArg, string sScreenName = null, int iPage = 1, int iCount = 20, int iUserId = -1, 
                                    int iMaxId = -1, bool bTrimUser = false, bool bIncludeRts = true, 
                                    bool bIncludeEntities = false)
        {
            Dictionary<string, string> dssParams = new Dictionary<string, string>();

            AddParameter(ref dssParams, "screen_name", sScreenName);
            AddParameter(ref dssParams, "page", iPage);
            AddParameter(ref dssParams, "count", iCount);
            AddParameter(ref dssParams, "user_id", iUserId);
            AddParameter(ref dssParams, "max_id", iMaxId);
            AddParameter(ref dssParams, "trim_user", bTrimUser);
            AddParameter(ref dssParams, "include_rts", bIncludeRts);
            AddParameter(ref dssParams, "include_entities", bIncludeEntities);

            DoRequest("statuses/user_timeline.json", WebMethod.Get, dssParams, new APIReturn(apcCallback, typeof(UserTimeline), objCallbackArg));
        }
Exemplo n.º 17
0
        private static void InvokeRpcAsync(RpcHandle handle, Guid iid, byte[] input, APICallback callback)
        {
            Log.Verbose("InvokeRpcAsync on {0}, sending {1} bytes", handle.Handle, input.Length);
              Ptr<MIDL_STUB_DESC> pStub;
              if (!handle.GetPtr(out pStub))
              {
            pStub = handle.CreatePtr(new MIDL_STUB_DESC(
              handle, handle.Pin(new RPC_CLIENT_INTERFACE(iid)), RpcApi.TYPE_FORMAT, false));
              }

              int cbOutput = 0;
              var pcbOutput = new Ptr<int>(cbOutput);
              IntPtr result = IntPtr.Zero;
              IntPtr output = IntPtr.Zero;
              var pOutput = new Ptr<IntPtr>(output);

              using (Ptr<byte[]> pInputBuffer = new Ptr<byte[]>(input))
              {
            AsyncCallback cbRountine = (IntPtr pAsync, IntPtr pContext, RpcAsyncEvent _event) =>
            {
              RPC_ASYNC_STATE async = (RPC_ASYNC_STATE)Marshal.PtrToStructure(pAsync, typeof(RPC_ASYNC_STATE));
              var myCallback = (APICallback)Marshal.GetDelegateForFunctionPointer(async.UserInfo, typeof(APICallback));

              RpcError hr = RpcApi.RpcAsyncCompleteCall(pAsync, ref result);
              if (RpcError.RPC_S_OK == hr)
              {
            if (RpcError.RPC_S_OK == (RpcError) result.ToInt32())
            {
              ExecuteAsyncResponse response;
              try
              {
                cbOutput = pcbOutput.Data;
                byte[] _output = new byte[cbOutput];
                Marshal.Copy(pOutput.Data, _output, 0, cbOutput);

                response.result = RpcError.RPC_S_OK;
                response.response = _output;
              }
              catch (Exception e)
              {
                response.result = RpcError.RPC_E_FAIL;
                response.response = null;
              }
              finally
              {
                RpcApi.Free(pOutput.Data);
              }

              myCallback(response);
            }
            else
            {
              ExecuteAsyncResponse response;
              response.result = (RpcError)result.ToInt32();
              response.response = null;
              myCallback(response);
            }
              }
              else
              {
            ExecuteAsyncResponse response;
            response.result = hr;
            response.response = null;
            myCallback(response);
              }
            };

            var pCallbackRoutine = new FunctionPtr<AsyncCallback>(cbRountine);

            RPC_ASYNC_STATE asyncState = new RPC_ASYNC_STATE();
            var _pAsyncState = new Ptr<RPC_ASYNC_STATE>(asyncState);
            RpcApi.RpcAsyncInitializeHandle(_pAsyncState.Handle, Marshal.SizeOf(typeof(RPC_ASYNC_STATE)));
            asyncState.Event = _pAsyncState.Data.Event;
            asyncState.Flags = _pAsyncState.Data.Flags;
            asyncState.Lock = _pAsyncState.Data.Lock;
            asyncState.RuntimeInfo = _pAsyncState.Data.RuntimeInfo;
            asyncState.Signature = _pAsyncState.Data.Signature;
            asyncState.Size = _pAsyncState.Data.Size;
            asyncState.StubInfo = _pAsyncState.Data.StubInfo;
            asyncState.NotificationType = RpcNotificationTypes.RpcNotificationTypeCallback;
            asyncState.u.NotificationRoutine = pCallbackRoutine.Handle;

            var ptrCB = Marshal.GetFunctionPointerForDelegate(callback);
            asyncState.UserInfo = ptrCB;

            var pAsyncState = new Ptr<RPC_ASYNC_STATE>(asyncState);

            if (RpcApi.Is64BitProcess)
            {
              try
              {
            result = RpcApi.NdrAsyncClientCallx64(pStub.Handle, RpcApi.ASYNC_FUNC_FORMAT_PTR.Handle, pAsyncState.Handle, handle.Handle,
              input.Length, pInputBuffer.Handle, out cbOutput, out output);
              }
              catch (SEHException ex)
              {
            RpcException.Assert(ex.ErrorCode);
            throw;
              }
            }
            else
            {
              using (Ptr<Int32[]> pStack32 = new Ptr<Int32[]>(new Int32[7]))
              {
            pStack32.Data[0] = pAsyncState.Handle.ToInt32();
            pStack32.Data[1] = handle.Handle.ToInt32();
            pStack32.Data[2] = input.Length;
            pStack32.Data[3] = pInputBuffer.Handle.ToInt32();
            pStack32.Data[4] = pcbOutput.Handle.ToInt32();
            pStack32.Data[5] = pOutput.Handle.ToInt32();
            pStack32.Data[6] = 0; //reserved

            try
            {
              result = RpcApi.NdrAsyncClientCallx86(pStub.Handle, RpcApi.ASYNC_FUNC_FORMAT_PTR.Handle, pStack32.Handle);
            }
            catch (SEHException ex)
            {
              Log.Verbose("exception on {0}", ex);
              RpcException.Assert(ex.ErrorCode);
              throw;
            }
              }
            }

            GC.KeepAlive(pInputBuffer);
              }
              RpcException.Assert(result.ToInt32());
              Log.Verbose("InvokeRpc.InvokeRpc response on {0}", handle.Handle);
        }
Exemplo n.º 18
0
 public void UpdateStatus(APICallback apcCallback, object objCallbackArg, string sMessage)
 {
     Dictionary<string, string> dssParams = new Dictionary<string, string>();
     dssParams["status"] = sMessage;
     DoRequest("statuses/update.json", WebMethod.Post, dssParams, new APIReturn(apcCallback, null, objCallbackArg));
 }