MsgPack.Rpc.Client.RpcClient.BeginNotify C# (CSharp) Method

BeginNotify() public method

Sends specified remote method with specified argument as notification message asynchronously.
/// is null. /// /// is not valid. ///
public BeginNotify ( string methodName, object arguments, AsyncCallback asyncCallback, object asyncState ) : IAsyncResult
methodName string /// The name of target method. ///
arguments object /// Argument to be passed to the server. /// All values must be able to be serialized with MessagePack serializer. ///
asyncCallback AsyncCallback /// The callback method invoked when the notification is sent or the reponse is received. /// This value can be null. /// Usually this callback get the result of invocation via . ///
asyncState object /// User supplied state object which can be gotten via in the callback. /// This value can be null. ///
return IAsyncResult
		public IAsyncResult BeginNotify( string methodName, object[] arguments, AsyncCallback asyncCallback, object asyncState )
		{
			this.VerifyIsNotDisposed();
			this.EnsureConnected();

			var asyncResult = new NotificationMessageAsyncResult( this, asyncCallback, asyncState );

			bool isSucceeded = false;
			var context = this._transport.GetClientRequestContext();
			try
			{
				context.SetNotification( methodName, asyncResult.OnCompleted );
				if ( arguments == null )
				{
					context.ArgumentsPacker.Pack( new MessagePackObject[ 0 ] );
				}
				else
				{
					context.ArgumentsPacker.PackArrayHeader( arguments.Length );
					foreach ( var arg in arguments )
					{
						if ( arg == null )
						{
							context.ArgumentsPacker.PackNull();
						}
						else
						{
							this._serializationContext.GetSerializer( arg.GetType() ).PackTo( context.ArgumentsPacker, arg );
						}
					}
				}

				this._transport.Send( context );
				isSucceeded = true;
			}
			finally
			{
				if ( !isSucceeded )
				{
					this._transport.ReturnContext( context );
				}
			}

			return asyncResult;
		}