public void HubCallAndResult(string method, Action <string> callback, params object[] args)
    {
        OnMethodResultDelegate onResult = (Hub hub, ClientMessage originalMessage, ResultMessage result) =>
        {
            VKDebug.LogColorRed("Lua Call reponse CallBack", method);
            callback(JsonConvert.SerializeObject(result.ReturnValue));
        };

        _hub.Call(method, onResult, args);
    }
Example #2
0
 public ClientMessage(BestHTTP.SignalR.Hubs.Hub hub, string method, object[] args, ulong callIdx, OnMethodResultDelegate resultCallback, OnMethodFailedDelegate resultErrorCallback, OnMethodProgressDelegate progressCallback)
 {
     this.Hub                 = hub;
     this.Method              = method;
     this.Args                = args;
     this.CallIdx             = callIdx;
     this.ResultCallback      = resultCallback;
     this.ResultErrorCallback = resultErrorCallback;
     this.ProgressCallback    = progressCallback;
 }
Example #3
0
 public ClientMessage(Hub hub, string method, object[] args, ulong callIdx, OnMethodResultDelegate resultCallback, OnMethodFailedDelegate resultErrorCallback, OnMethodProgressDelegate progressCallback)
 {
     Hub                 = hub;
     Method              = method;
     Args                = args;
     CallIdx             = callIdx;
     ResultCallback      = resultCallback;
     ResultErrorCallback = resultErrorCallback;
     ProgressCallback    = progressCallback;
 }
Example #4
0
        public bool Call(string method, OnMethodResultDelegate onResult, OnMethodFailedDelegate onResultError, OnMethodProgressDelegate onProgress, params object[] args)
        {
            lock (((IHub)this).Connection.SyncRoot)
            {
                ((IHub)this).Connection.ClientMessageCounter %= ulong.MaxValue;
                return(((IHub)this).Call(new ClientMessage(this, method, args, ((IHub)this).Connection.ClientMessageCounter++, onResult, onResultError, onProgress)));

IL_0058:
                bool result;
                return(result);
            }
        }
Example #5
0
        /// <summary>
        /// Orders the server to call a method with the given arguments.
        /// The onResult callback will be called when the server successfully called the function.
        /// The onResultError will be called when the server can't call the function, or when the function throws an exception.
        /// The onProgress callback called multiple times when the method is a long runnning function and reports back its progress.
        /// </summary>
        /// <returns>True if the plugin was able to send out the message</returns>
        public bool Call(string method, OnMethodResultDelegate onResult, OnMethodFailedDelegate onResultError, OnMethodProgressDelegate onProgress, params object[] args)
        {
            IHub thisHub = this as IHub;

            lock (thisHub.Connection.SyncRoot)
            {
                // Start over the counter if we are reached the max value if the UInt64 type.
                // While we are using this property only here, we don't want to make it static to avoid another thread syncronization, neither we want to make it a Hub-instance field to achieve better deuggability.
                thisHub.Connection.ClientMessageCounter %= UInt64.MaxValue;

                // Create and send the client message
                return(thisHub.Call(new ClientMessage(this, method, args, thisHub.Connection.ClientMessageCounter++, onResult, onResultError, onProgress)));
            }
        }
    public void HubCallAndCallbak(string method, Action <string> callbackResult, Action <string> callbackError, Action <string> callbackProgress, params object[] args)
    {
        OnMethodResultDelegate onResult = (Hub hub, ClientMessage originalMessage, ResultMessage result) =>
        {
            callbackResult(JsonConvert.SerializeObject(result.ReturnValue));
        };
        OnMethodFailedDelegate onResultError = (Hub hub, ClientMessage originalMessage, FailureMessage error) =>
        {
            callbackError(JsonConvert.SerializeObject(error));
        };
        OnMethodProgressDelegate onProgress = (Hub hub, ClientMessage originialMessage, ProgressMessage progress) =>
        {
            callbackError(JsonConvert.SerializeObject(progress));
        };

        _hub.Call(method, onResult, onResultError, onProgress, args);
    }
Example #7
0
        /// <summary>
        /// Orders the server to call a method with the given arguments.
        /// The onResult callback will be called when the server successfully called the function.
        /// The onResultError will be called when the server can't call the function, or when the function throws an exception.
        /// The onProgress callback called multiple times when the method is a long running function and reports back its progress.
        /// </summary>
        /// <returns>True if the plugin was able to send out the message</returns>
        public bool Call(string method, OnMethodResultDelegate onResult, OnMethodFailedDelegate onResultError, OnMethodProgressDelegate onProgress, params object[] args)
        {
            IHub thisHub = this as IHub;

            // Start over the counter if we are reached the max value if the long type.
            // While we are using this property only here, we don't want to make it static to avoid another thread synchronization, neither we want to make it a Hub-instance field to achieve better debuggability.

            long newValue, originalValue;

            do
            {
                originalValue = thisHub.Connection.ClientMessageCounter;
                newValue      = (originalValue % long.MaxValue) + 1;
            } while (System.Threading.Interlocked.CompareExchange(ref thisHub.Connection.ClientMessageCounter, newValue, originalValue) != originalValue);

            // Create and send the client message
            return(thisHub.Call(new ClientMessage(this, method, args, (ulong)thisHub.Connection.ClientMessageCounter, onResult, onResultError, onProgress)));
        }
        public ClientMessage(Hub hub,
                             string method, 
                             object[] args, 
                             UInt64 callIdx, 
                             OnMethodResultDelegate resultCallback,
                             OnMethodFailedDelegate resultErrorCallback, 
                             OnMethodProgressDelegate progressCallback)
        {
            Hub = hub;
            Method = method;
            Args = args;

            CallIdx = callIdx;

            ResultCallback = resultCallback;
            ResultErrorCallback = resultErrorCallback;
            ProgressCallback = progressCallback;
        }
 /// <summary>
 /// Orders the server to call a method with the given arguments.
 /// The onResult callback will be called when the server successfully called the function.
 /// </summary>
 /// <returns>True if the plugin was able to send out the message</returns>
 public bool Call(string method, OnMethodResultDelegate onResult, params object[] args)
 {
     return Call(method, onResult, null, null, args);
 }
Example #10
0
 /// <summary>
 /// Orders the server to call a method with the given arguments.
 /// The onResult callback will be called when the server successfully called the function.
 /// The onProgress callback called multiple times when the method is a long runnning function and reports back its progress.
 /// </summary>
 public void Call(string method, OnMethodResultDelegate onResult, OnMethodProgressDelegate onProgress, params object[] args)
 {
     Call(method, onResult, null, onProgress, args);
 }
Example #11
0
 /// <summary>
 /// Orders the server to call a method with the given arguments.
 /// The onResult callback will be called when the server successfully called the function.
 /// The onResultError will be called when the server can't call the function, or when the function throws an exception.
 /// </summary>
 /// <returns>True if the plugin was able to send out the message</returns>
 public bool Call(string method, OnMethodResultDelegate onResult, OnMethodFailedDelegate onResultError, params object[] args)
 {
     return(Call(method, onResult, onResultError, null, args));
 }
Example #12
0
 /// <summary>
 /// Orders the server to call a method with the given arguments.
 /// The onResult callback will be called when the server successfully called the function.
 /// The onProgress callback called multiple times when the method is a long runnning function and reports back its progress.
 /// </summary>
 /// <returns>True if the plugin was able to send out the message</returns>
 public bool Call(string method, OnMethodResultDelegate onResult, OnMethodProgressDelegate onProgress, params object[] args)
 {
     return(Call(method, onResult, null, onProgress, args));
 }
Example #13
0
 /// <summary>
 /// Orders the server to call a method with the given arguments.
 /// The onResult callback will be called when the server successfully called the function.
 /// The onProgress callback called multiple times when the method is a long runnning function and reports back its progress.
 /// </summary>
 public void Call(string method, OnMethodResultDelegate onResult, OnMethodProgressDelegate onProgress, params object[] args)
 {
     Call(method, onResult, null, onProgress, args);
 }
Example #14
0
 /// <summary>
 /// Orders the server to call a method with the given arguments.
 /// The onResult callback will be called when the server successfully called the function.
 /// The onResultError will be called when the server can't call the function, or when the function throws an exception.
 /// </summary>
 public void Call(string method, OnMethodResultDelegate onResult, OnMethodFailedDelegate onResultError, params object[] args)
 {
     Call(method, onResult, onResultError, null, args);
 }
Example #15
0
 /// <summary>
 /// Orders the server to call a method with the given arguments.
 /// The onResult callback will be called when the server successfully called the function.
 /// The onResultError will be called when the server can't call the function, or when the function throws an exception.
 /// </summary>
 public void Call(string method, OnMethodResultDelegate onResult, OnMethodFailedDelegate onResultError, params object[] args)
 {
     Call(method, onResult, onResultError, null, args);
 }
Example #16
0
        /// <summary>
        /// Orders the server to call a method with the given arguments.
        /// The onResult callback will be called when the server successfully called the function.
        /// The onResultError will be called when the server can't call the function, or when the function throws an exception.
        /// The onProgress callback called multiple times when the method is a long runnning function and reports back its progress.
        /// </summary>
        public void Call(string method, OnMethodResultDelegate onResult, OnMethodFailedDelegate onResultError, OnMethodProgressDelegate onProgress, params object[] args)
        {
            IHub thisHub = this as IHub;

            lock (thisHub.Connection.SyncRoot)
            {
                // Start over the counter if we are reached the max value if the UInt64 type.
                // While we are using this property only here, we don't want to make it static to avoid another thread syncronization, neither we want to make it a Hub-instance field to achieve better deuggability.
                thisHub.Connection.ClientMessageCounter %= UInt64.MaxValue;

                // Create and send the client message
                thisHub.Call(new ClientMessage(this, method, args, thisHub.Connection.ClientMessageCounter++, onResult, onResultError, onProgress));
            }
        }
	public void HubCall(string method, OnMethodResultDelegate onResult, params object[] args)
	{
		_hub.Call(method, onResult, args);
	}