public MessageItem(MessageCallback call, string content, string cap, Buttons btns, DefaultButton defaultBtn)
 {
     this.message = content;
     this.caption = cap;
     this.buttons = btns;
     this.defaultButton = defaultBtn;
 }
        void HandleFromGC( IPacketMsg packetMsg )
        {
            var msg = new ClientMsgProtobuf<CMsgGCClient>( packetMsg );

            var callback = new MessageCallback( msg.Body );
            this.Client.PostCallback( callback );
        }
 public DefaultBasicConsumer CreateConsumer(IModel model, MessageCallback callback)
 {
     var consumer = new QueueingBasicConsumer(model, sharedQueue);
     var consumerTag = Guid.NewGuid().ToString();
     consumer.ConsumerTag = consumerTag;
     callbacks.Add(consumerTag, callback);
     return consumer;
 }
Example #4
0
        /// <summary>
        /// Handles a client message. This should not be called directly.
        /// </summary>
        /// <param name="packetMsg">The packet message that contains the data.</param>
        public override void HandleMsg( IPacketMsg packetMsg )
        {
            if ( packetMsg.MsgType == EMsg.ClientFromGC )
            {
                var msg = new ClientMsgProtobuf<CMsgGCClient>( packetMsg );

                var callback = new MessageCallback( msg.Body );
                this.Client.PostCallback( callback );
            }
        }
        public DefaultBasicConsumer CreateConsumer(
            SubscriptionAction subscriptionAction, 
            IModel model, 
            bool modelIsSingleUse, 
            MessageCallback callback)
        {
            var consumer = new EasyNetQConsumer(model, queue);
            var consumerTag = Guid.NewGuid().ToString();
            consumer.ConsumerTag = consumerTag;
            subscriptions.Add(consumerTag, new SubscriptionInfo(subscriptionAction, consumer, callback, modelIsSingleUse, model));

            return consumer;
        }
        /// <summary>
        /// Handles a client message. This should not be called directly.
        /// </summary>
        /// <param name="packetMsg">The packet message that contains the data.</param>
        public override void HandleMsg( IPacketMsg packetMsg )
        {
            if ( packetMsg.MsgType == EMsg.ClientFromGC )
            {
                var msg = new ClientMsgProtobuf<CMsgGCClient>( packetMsg );

#if STATIC_CALLBACKS
                var callback = new MessageCallback( Client, msg.Body );
                SteamClient.PostCallback( callback );
#else
                var callback = new MessageCallback( msg.Body );
                this.Client.PostCallback( callback );
#endif
            }
        }
Example #7
0
        public void ParseMessage(string cipher, MessageCallback mcb, ErrorCallback ecb, bool retry = true)
        {
            bool success = true;

            try {
                var line = aes.Decipher(cipher);
                var json = Json.JsonDecode(line, ref success);

                if (success && json is Dictionary<string, object>) {
                    var data = json as Dictionary<string, object>;

                    var message = new Message();

                    message.From = data["from"] as string;
                    message.Time =
                        new DateTime(1970, 1, 1, 0, 0, 0, 0).AddMilliseconds(
                            long.Parse(data["time"].ToString().Split(new[] { '.' })[0])
                        ).ToLocalTime();
                    if (data.ContainsKey("type")) message.Type = data["type"] as string;
                    if (data.ContainsKey("body")) message.Body = data["body"] as string;
                    if (data.ContainsKey("otr")) message.OTR = true.Equals(data["otr"]);
                    if (data.ContainsKey("typing")) message.Typing = true.Equals(data["typing"]);
                    message.Outbound = false;

                    mcb(message);
                } else {
                    ecb("Invalid JSON");
                }
            } catch (NullReferenceException) {
                ecb("Invalid JSON");
            } catch (System.Security.Cryptography.CryptographicException) {
                // Get key again
                if (retry) {
                    GetKey(
                        key => ParseMessage(cipher, mcb, ecb, false),
                        error => ecb(error)
                    );
                } else {
                    ecb("Invalid decryption key");
                }
            }
        }
Example #8
0
            int state;  // 0: created, 1: waiting, 2: signaled

            public AsyncWaiter(ReceiverLink link, MessageCallback callback)
            {
                this.link = link;
                this.callback = callback;
            }
 public DefaultBasicConsumer CreateConsumer(IModel model, MessageCallback callback)
 {
     return new CallbackConsumer(model, callback);
 }
Example #10
0
 public static extern void ass_set_message_cb(
     IntPtr library,
     [MarshalAs(UnmanagedType.FunctionPtr)][CanBeNull]
     MessageCallback callback,
     IntPtr userData);
Example #11
0
 public static void Print(MessageCallback msg)
 {
     Print(msg.Format());
 }
Example #12
0
 public static void UnregisterClientMessageCallback(byte id, MessageCallback callback)
 {
     clientMsgCallbacks.Remove(id, callback);
 }
Example #13
0
 public static void RegisterClientMessageCallback(byte id, MessageCallback callback, CallbackPriority priority)
 {
     clientMsgCallbacks.Add(id, callback, priority);
 }
Example #14
0
 private void Output(string message)
 {
     MessageCallback?.Invoke(message);
 }
Example #15
0
 /// <summary>
 /// Shows a message box
 /// </summary>
 /// <param name="callback">The method to call once the user has taken a action.</param>
 /// <param name="message">The text label of the message box</param>
 /// <param name="caption">The caption of the window</param>
 /// <param name="buttons">The buttons to display on the message box</param>
 public static void Show(MessageCallback callback, string message, string caption, MessageBoxButtons buttons)
 {
     Show(callback, message, caption, buttons, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
 }
Example #16
0
 public void Message(string text)
 {
     TaskHelper.Run(() => MessageCallback?.Invoke(text), taskScheduler);
 }
Example #17
0
 public MessageItem(MessageCallback call, string content, string cap, ButtonStyle btns)
 {
     this.message = content;
     this.caption = cap;
     this.buttons = btns;
 }
Example #18
0
        public static string RecognizeProcess(string[] args, bool multiThread = true, bool flagOff = true, bool toPhone = false)
        {
            if (resultCode != -1)
            {
                string dictFile = null;
                result     = null;
                error      = null;
                resultCode = -1;
                bool isTime = false;

                int i = 0;
                foreach (string arg in args)
                {
                    if (arg == "-dict")
                    {
                        dictFile = args[i + 1];
                    }

                    if (arg == "-time")
                    {
                        isTime = true;
                    }
                    i++;
                }

                MessageCallback msgCallback = (value) => {
                    if (value.Contains("ERROR") || value.Contains("FATAL"))
                    {
                        Debug.LogError("[AutoSync] " + value);
                        error = "FAILED";
                    }
                };

                ResultCallback resCallback = (value) => {
                    result = value;
                    if (toPhone && dictFile != null)
                    {
                        string[] words = new string[0];

                        if (isTime)
                        {
                            result = result.Replace("<s>", "SIL").Replace("</s>", "SIL").Replace("<sil>", "SIL");

                            words = result.Split('\n');
                            string[] timeMark = new string[words.Length];
                            i = 0;
                            foreach (string word in words)
                            {
                                int pos = word.IndexOf(" ");
                                if (pos > 0)
                                {
                                    words[i]    = word.Substring(0, pos);
                                    timeMark[i] = word.Substring(pos, word.Length - pos);
                                }
                                i++;
                            }
                            string[] phonemes = ConvertToPhonemes(dictFile, words);
                            for (i = 0; i < phonemes.Length; i++)
                            {
                                phonemes[i] = phonemes[i].TrimStart() + timeMark[i] + "\r\n";
                                Debug.Log(phonemes[i]);
                            }
                            result = String.Join("", phonemes);
                        }
                        else
                        {
                            words = result.Split(' ');
                            string[] phonemes = ConvertToPhonemes(dictFile, words);
                            result = String.Join(" ", phonemes);
                        }

                        dataReady = true;
                    }
                    else
                    {
                        dataReady = true;
                    }
                };

                int argsCount = args.Length;

                try {
                    if (multiThread)
                    {
                        Thread thread = new Thread(new ThreadStart(() => {
                            resultCode = psRun(msgCallback, resCallback, argsCount, args);
                            isFinished = true;
                        }));
                        thread.Start();
                    }
                    else
                    {
                        resultCode = psRun(msgCallback, resCallback, argsCount, args);
                        isFinished = true;
                    }
                } catch (Exception e) {
                    error = "FAILED: " + e.Message;
                    return(error);
                }
            }
            else
            {
                Debug.Log("SphinxWrapper is busy. Please wait and try again.");
            }

            return(result);
        }
Example #19
0
 public static extern int psRun([MarshalAs(UnmanagedType.FunctionPtr)] MessageCallback msgCallbackPtr, [MarshalAs(UnmanagedType.FunctionPtr)] ResultCallback resCallbackPtr, int argsCount, string[] argsArray);
Example #20
0
 public static void UnregisterClientMessageCallback(byte id, MessageCallback callback)
 {
     clientMsgCallbacks.Remove(id, callback);
 }
Example #21
0
 public MessageItem(MessageLevel level, string title, string message, MessageCallback callback)
     : this(level, title, message)
 {
     Callback = callback;
 }
    public static void Show(MessageCallback callback, string message, string caption, Buttons buttons, Icon icon, MessageBox.DefaultButton defaultButton)
    {
		//if(string.IsNullOrEmpty(caption))
			//caption = AvLocalizationManager.GetString(6);
        MessageItem item = new MessageItem
        {
            caption = caption,
            buttons = buttons,
            defaultButton = defaultButton,
            callback = callback
        };
        item.message = message;
        switch (icon)
        {
            case Icon.Hand:
            case Icon.Stop:
            case Icon.Error:
                //item.message.image = messageHandler.error;
                break;

            case Icon.Exclamation:
            case Icon.Warning:
                //item.message.image = messageHandler.warning;
                break;

            case Icon.Asterisk:
            case Icon.Information:
                //item.message.image = messageHandler.info;
                break;
        }
        if (items.Count > 2)
        {
            items.RemoveAt(0);
        }
        items.Add(item);

		AvUIManager.instance.ShowDialog(DialogName.MessageBox, item);
    }
Example #23
0
 public static void RegisterClientMessageCallback(byte id, MessageCallback callback, CallbackPriority priority)
 {
     clientMsgCallbacks.Add(id, callback, priority);
 }
Example #24
0
 public static void RegisterServerMessageCallback(byte id, MessageCallback callback, CallbackPriority priority)
 {
     serverMsgCallbacks.Add(id, callback, priority);
 }
Example #25
0
        void ReceiveByteWithEscaping(byte b, MessageCallback framingErrorCallback)
        {
            if (b == Constants.Bof)
            {
                if (framingErrorCallback != null)
                {
                    framingErrorCallback("S101: BOF in frame!");
                }

                _stream.SetLength(0);
                _isDataLinkEscaped = false;
                _crc = Crc.InitialValue;

                if (_outOfFrameByteCount > 0 && framingErrorCallback != null)
                {
                    framingErrorCallback(String.Format("S101: {0} out of frame data bytes!", _outOfFrameByteCount));
                }

                _outOfFrameByteCount = 0;
                return;
            }

            if (b == Constants.Eof)
            {
                var length = (int)_stream.Length;
                _stream.Write(Constants.Eofs, 0, Constants.Eofs.Length);

                if (length >= 3)
                {
                    if (_crc == 0xF0B8)
                    {
                        _stream.SetLength(length - 2);
                        var memory = _stream.ToArray();
                        OnMessageReceived(new MessageReceivedArgs(memory.Length, memory, false), true);
                    }
                    else
                    {
                        if (framingErrorCallback != null)
                        {
                            framingErrorCallback("S101: CRC error!");
                        }
                    }
                }
                else if (length == 0)
                {
                    if (framingErrorCallback != null)
                    {
                        framingErrorCallback("S101: EOF out of frame!");
                    }
                }

                _isInFrame = false;
                _stream.SetLength(0);
                return;
            }

            if (b == Constants.Ce)
            {
                _isDataLinkEscaped = true;
                return;
            }

            if (b >= Constants.Invalid)
            {
                if (framingErrorCallback != null)
                {
                    framingErrorCallback("S101: Invalid character received!");
                }

                _isInFrame = false;
                _stream.SetLength(0);
                return;
            }

            if (_isDataLinkEscaped)
            {
                _isDataLinkEscaped = false;
                b ^= 0x20;
            }

            _stream.WriteByte(b);
            _crc = Crc.CrcCCITT16(_crc, b);
        }
Example #26
0
 public static void UnregisterServerMessageCallback(byte id, MessageCallback callback)
 {
     serverMsgCallbacks.Remove(id, callback);
 }
 public static void Show(MessageCallback callback, string message)
 {
     Show(callback, message, string.Empty, Buttons.OK, Icon.None, MessageBox.DefaultButton.Button1);
 }
Example #28
0
 extern static OpenSslHandle native_openssl_initialize(int debug, NativeOpenSslProtocol protocol, DebugCallback debug_callback, MessageCallback message_callback);
Example #29
0
 private void DoMessage(string message)
 {
     MessageCallback?.Invoke(message);
 }
Example #30
0
 public void RequestAsync(string message, string data, MessageCallback callback)
 {
 }
Example #31
0
 public void OnMessageFromServer(string message, MessageCallback callback)
 {
 }
Example #32
0
 /// <summary>
 ///     Creates a local message hook and hooks it.
 /// </summary>
 /// <param name="callback"></param>
 public LocalMessageHook(MessageCallback callback)
     : this()
 {
     MessageOccurred = callback;
     StartHook();
 }
Example #33
0
 public string subscribe(string uid, PythonDictionary filter, MessageCallback callback)
 {
     return(_messageBusService.Subscribe(uid, filter, m => { callback(PythonConvert.ToPythonDictionary(m)); }));
 }
        static void Run(CancellationTokenSource cts)
        {
            ushort            port    = 8080;
            NetworkingSockets server  = new NetworkingSockets();
            Address           address = new Address();

            address.SetAddress("::0", port);

            uint listenSocket = server.CreateListenSocket(ref address);

            StatusCallback status = (info, context) => {
                switch (info.connectionInfo.state)
                {
                case ConnectionState.None:
                    break;

                case ConnectionState.Connecting:
                    server.AcceptConnection(info.connection);
                    break;

                case ConnectionState.Connected:
                    Console.WriteLine("Client connected - ID: " + info.connection + ", IP: " + info.connectionInfo.address.GetIP());
                    break;

                case ConnectionState.ClosedByPeer:
                    server.CloseConnection(info.connection);
                    Console.WriteLine("Client disconnected - ID: " + info.connection + ", IP: " + info.connectionInfo.address.GetIP());
                    break;
                }
            };

#if VALVESOCKETS_SPAN
            MessageCallback message = (in NetworkingMessage netMessage) => {
                Console.WriteLine("Message received from - ID: " + netMessage.connection + ", Channel ID: " + netMessage.channel + ", Data length: " + netMessage.length);
            };
#else
            const int maxMessages = 20;

            NetworkingMessage[] netMessages = new NetworkingMessage[maxMessages];
#endif

            while (!cts.IsCancellationRequested)
            {
                server.DispatchCallback(status);

#if VALVESOCKETS_SPAN
                server.ReceiveMessagesOnListenSocket(listenSocket, message, 20);
#else
                int netMessagesCount = server.ReceiveMessagesOnListenSocket(listenSocket, netMessages, maxMessages);

                if (netMessagesCount > 0)
                {
                    for (int i = 0; i < netMessagesCount; i++)
                    {
                        ref NetworkingMessage netMessage = ref netMessages[i];

                        Console.WriteLine("Message received from - ID: " + netMessage.connection + ", Channel ID: " + netMessage.channel + ", Data length: " + netMessage.length);

                        netMessage.Destroy();
                    }
                }
#endif

                Thread.Sleep(15);
            }
Example #35
0
        internal Message ReceiveInternal(MessageCallback callback, int timeout = 60000)
        {
            Waiter waiter = null;
            lock (this.ThisLock)
            {
                this.ThrowIfDetaching("Receive");
                MessageNode first = (MessageNode)this.receivedMessages.First;
                if (first != null)
                {
                    this.receivedMessages.Remove(first);
                    this.OnDeliverMessage();
                    return first.Message;
                }

                if (timeout > 0)
                {
#if NETFX || NETFX40 || DOTNET || NETFX_CORE || WINDOWS_STORE || WINDOWS_PHONE
                    waiter = callback == null ? (Waiter)new SyncWaiter() : new AsyncWaiter(this, callback);
#else
                    waiter = new SyncWaiter();
#endif
                    this.waiterList.Add(waiter);
                }
            }

            // send credit after waiter creation to avoid race condition
            if (this.totalCredit < 0)
            {
                this.SetCredit(DefaultCredit, true);
            }

            return timeout > 0 ? waiter.Wait(timeout) : null;
        }
Example #36
0
 /// <summary>
 /// Shows a message box
 /// </summary>
 /// <param name="callback">The method to call once the user has taken a action.</param>
 /// <param name="message">The text label of the message box</param>
 public static void Show(MessageCallback callback, string message)
 {
     Show(callback, message, "", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
 }
Example #37
0
 /// <summary>
 /// Starts the message pump.
 /// </summary>
 /// <param name="credit">The link credit to issue.</param>
 /// <param name="onMessage">If specified, the callback to invoke when messages are received.
 /// If not specified, call Receive method to get the messages.</param>
 public void Start(int credit, MessageCallback onMessage = null)
 {
     this.onMessage = onMessage;
     this.SetCredit(credit, true);
 }
Example #38
0
 /// <summary>
 /// Shows a message box
 /// </summary>
 /// <param name="callback">The method to call once the user has taken a action.</param>
 /// <param name="message">The text label of the message box</param>
 /// <param name="caption">The caption of the window</param>
 /// <param name="buttons">The buttons to display on the message box</param>
 /// <param name="icon">The icon to display on the message box.</param>
 public static void Show(MessageCallback callback, string message, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
 {
     Show(callback, message, caption, buttons, icon, MessageBoxDefaultButton.Button1);
 }
Example #39
0
 public void MessageQueue(MessageCallback mcb, ErrorCallback ecb, FinishedCallback fcb)
 {
     Send(
         "/messagequeue",
         ReceiveMode.Lines,
         sw => sw.Write("token=" + HttpUtility.UrlEncode(token)),
         cipher => ParseMessage(cipher, mcb, ecb),
         null,
         ecb,
         fcb
     );
 }
Example #40
0
 extern public VideoPlayback CreateVideoPlayback(string fileName, MessageCallback errorCallback, Callback readyCallback, Callback reachedEndCallback, bool splitAlpha = false);
Example #41
0
 public DefaultBasicConsumer CreateConsumer(SubscriptionAction subscriptionAction, IModel model, bool modelIsSingleUse, MessageCallback callback)
 {
     return null;
 }
Example #42
0
 public static extern MessageCallback SetOnMessageHandler(IntPtr instance, MessageCallback messageCallback);
Example #43
0
        /// <summary>
        /// This should be called by the connection engine for every byte that has
        /// been received. ReceiveByte raises the MessageReceived event when a complete message
        /// has been received.
        /// </summary>
        /// <param name="b">received byte to process</param>
        /// <param name="framingErrorCallback">callback function that is invoked everytime a framing error is encountered</param>
        public void ReceiveByte(byte b, MessageCallback framingErrorCallback)
        {
            if(_isInFrame == false)
             {
            if(b == Constants.Bof)
            {
               _stream.SetLength(0);
               _isDataLinkEscaped = false;
               _crc = Crc.InitialValue;
               _isInFrame = true;

               if(_outOfFrameByteCount > 0 && framingErrorCallback != null)
                  framingErrorCallback(string.Format("S101: {0} out of frame data bytes!", _outOfFrameByteCount));

               _outOfFrameByteCount = 0;
            }
            else
            {
               _outOfFrameByteCount++;
            }

            return;
             }

             if(b == Constants.Bof)
             {
            if(framingErrorCallback != null)
               framingErrorCallback("S101: BOF in frame!");

            _stream.SetLength(0);
            _isDataLinkEscaped = false;
            _crc = Crc.InitialValue;

            if(_outOfFrameByteCount > 0 && framingErrorCallback != null)
               framingErrorCallback(String.Format("S101: {0} out of frame data bytes!", _outOfFrameByteCount));

            _outOfFrameByteCount = 0;
            return;
             }

             if(b == Constants.Eof)
             {
            var length = (int)_stream.Length;
            _stream.Write(Constants.Eofs, 0, Constants.Eofs.Length);

            if(length >= 3)
            {
               if(_crc == 0xF0B8)
               {
                  _stream.SetLength(length - 2);
                  var memory = _stream.ToArray();
                  OnMessageReceived(new MessageReceivedArgs(memory.Length, memory));
               }
               else
               {
                  if(framingErrorCallback != null)
                     framingErrorCallback("S101: CRC error!");
               }
            }
            else if(length == 0)
            {
               if(framingErrorCallback != null)
                  framingErrorCallback("S101: EOF out of frame!");
            }

            _isInFrame = false;
            _stream.SetLength(0);
            return;
             }

             if(b == Constants.Ce)
             {
            _isDataLinkEscaped = true;
            return;
             }

             if(b >= Constants.Invalid)
             {
            if(framingErrorCallback != null)
               framingErrorCallback("S101: Invalid character received!");

            _isInFrame = false;
            _stream.SetLength(0);
            return;
             }

             if(_isDataLinkEscaped)
             {
            _isDataLinkEscaped = false;
            b ^= 0x20;
             }

             _stream.WriteByte(b);
             _crc = Crc.CrcCCITT16(_crc, b);
        }
 public MyCallbackTime(MessageCallback <TMsg> callback)
 {
     this.Callback = callback;
 }
Example #45
0
 public static void RegisterServerMessageCallback(byte id, MessageCallback callback, CallbackPriority priority)
 {
     serverMsgCallbacks.Add(id, callback, priority);
 }
 public MyCallbackEntity(MySyncLayer layer, MessageCallback <TSync, TMsg> callback)
 {
     this.Callback = callback;
     this.Layer    = layer;
 }
Example #47
0
 public static void UnregisterServerMessageCallback(byte id, MessageCallback callback)
 {
     serverMsgCallbacks.Remove(id, callback);
 }
Example #48
0
 UnregisterMessageCallback(MessageCallback registeredCallback)
 {
     bool status = NativeMethods.WimUnregisterMessageCallback(IntPtr.Zero, registeredCallback);
     int rc = Marshal.GetLastWin32Error();
     if (status != true)
     {
         //
         // Throw an exception.
         //
         throw new System.InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Unable to unregister message callback."));
     }
 }
Example #49
0
 /// <summary>
 /// Shows a message box
 /// </summary>
 /// <param name="callback">The method to call once the user has taken a action.</param>
 /// <param name="message">The text label of the message box</param>
 public static void Show(MessageCallback callback, string message)
 {
     Show(callback, message, "", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
 }
Example #50
0
        private void SignInternal(MessageCallback <string> callback)
        {
            const decimal factor = 1000000;

            var fee = Utils.TryGetNumber <decimal>(_txJson.Fee);

            if (fee == null)
            {
                fee = (decimal)Config.Fee;
            }
            _txJson.Fee = fee.Value / factor;

            //payment
            var amount = Utils.TryGetNumber <decimal>(_txJson.Amount);

            if (amount.HasValue)
            {
                _txJson.Amount = amount / factor;
            }

            if (_txJson.Memos != null)
            {
                foreach (var memo in _txJson.Memos)
                {
                    memo.Memo.MemoData = Encoding.UTF8.GetString(Utils.HexToBytes(memo.Memo.MemoData));
                }
            }

            var sendMax = Utils.TryGetNumber <decimal>(_txJson.SendMax);

            if (sendMax.HasValue)
            {
                _txJson.SendMax = sendMax / factor;
            }

            // order
            var offerCreateTxData = _txJson as OfferCreateTxData;

            if (offerCreateTxData != null)
            {
                var takerPays = Utils.TryGetNumber <decimal>(offerCreateTxData.TakerPays);
                if (takerPays.HasValue)
                {
                    offerCreateTxData.TakerPays = takerPays / factor;
                }

                var takerGets = Utils.TryGetNumber <decimal>(offerCreateTxData.TakerGets);
                if (takerGets.HasValue)
                {
                    offerCreateTxData.TakerGets = takerGets / factor;
                }
            }

            var wt     = Wallet.FromSecret(_secret);
            var pubKey = Utils.BytesToHex(wt.GetPublicKey().ToByteArray());

            _txJson.SigningPubKey = pubKey;

            // The TxnSignature is different for each Sign with the same hash.
            // the TxnSignature is set for unit test
            if (_txJson.TxnSignature == null)
            {
                var so   = Serializer.Create(_txJson);
                var hash = so.Hash(0x53545800);
                _txJson.TxnSignature = wt.Sign(hash);
            }

            var soTx = Serializer.Create(_txJson);

            _txJson.Blob = soTx.ToHex();
            _localSigned = true;

            callback(new MessageResult <string>(null, null, _txJson.Blob));
        }
Example #51
0
    /// <summary>
    /// Shows a message box
    /// </summary>
    /// <param name="callback">The method to call once the user has taken a action.</param>
    /// <param name="message">The text label of the message box</param>
    /// <param name="caption">The caption of the window</param>
    /// <param name="buttons">The buttons to display on the message box</param>
    /// <param name="icon">The icon to display on the message box.</param>
    /// <param name="defaultButton">The default button to be selected.</param>
    public static void Show(MessageCallback callback, string message, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
    {
        MessageItem item = new MessageItem();
        item.caption = caption;
        item.buttons = buttons;
        item.defaultButton = defaultButton;
        item.callback = callback;
        item.message.text = message;

        switch (icon)
        {
            case MessageBoxIcon.Error:
            case MessageBoxIcon.Stop:
            case MessageBoxIcon.Hand:
                item.message.image = i.error;
                break;
            case MessageBoxIcon.Exclamation:
            case MessageBoxIcon.Warning:
                item.message.image = i.warning;
                break;
            case MessageBoxIcon.Information:
            case MessageBoxIcon.Asterisk:
                item.message.image = i.info;
                break;
            default:
                break;
        }

        items.Add(item);
    }
 public SubscriptionInfo(IBasicConsumer consumer, MessageCallback callback)
 {
     Consumer = consumer;
     Callback = callback;
 }
 public static void Show(MessageCallback callback, string message, string caption, Buttons buttons, Icon icon)
 {
     Show(callback, message, caption, buttons, icon, MessageBox.DefaultButton.Button1);
 }
Example #54
0
		extern static OpenSslHandle native_openssl_initialize (int debug, NativeOpenSslProtocol protocol, DebugCallback debug_callback, MessageCallback message_callback);
Example #55
0
        internal override void OnTransfer(Delivery delivery, Transfer transfer, ByteBuffer buffer)
        {
            if (delivery == null)
            {
                delivery = this.deliveryCurrent;
                AmqpBitConverter.WriteBytes(delivery.Buffer, buffer.Buffer, buffer.Offset, buffer.Length);
            }
            else
            {
                buffer.AddReference();
                delivery.Buffer = buffer;
                lock (this.ThisLock)
                {
                    this.OnDelivery(transfer.DeliveryId);
                }
            }

            if (!transfer.More)
            {
                this.deliveryCurrent = null;
                delivery.Message     = Message.Decode(delivery.Buffer);

                Waiter          waiter;
                MessageCallback callback = this.onMessage;
                lock (this.ThisLock)
                {
                    waiter = (Waiter)this.waiterList.First;
                    if (waiter != null)
                    {
                        this.waiterList.Remove(waiter);
                    }
                    else if (callback == null)
                    {
                        this.receivedMessages.Add(new MessageNode()
                        {
                            Message = delivery.Message
                        });
                        return;
                    }
                }

                while (waiter != null)
                {
                    if (waiter.Signal(delivery.Message))
                    {
                        return;
                    }

                    lock (this.ThisLock)
                    {
                        waiter = (Waiter)this.waiterList.First;
                        if (waiter != null)
                        {
                            this.waiterList.Remove(waiter);
                        }
                        else if (callback == null)
                        {
                            this.receivedMessages.Add(new MessageNode()
                            {
                                Message = delivery.Message
                            });
                            return;
                        }
                    }
                }

                Fx.Assert(waiter == null, "waiter must be null now");
                Fx.Assert(callback != null, "callback must not be null now");
                callback(this, delivery.Message);
            }
            else
            {
                this.deliveryCurrent = delivery;
            }
        }
Example #56
0
 public void RegisterMessageImmediate <TMsg>(MessageCallback <TMsg> callback, MyMessagePermissions permissions, MyTransportMessageEnum messageType = MyTransportMessageEnum.Request, ISerializer <TMsg> serializer = null)
     where TMsg : struct
 {
     TransportLayer.Register <TMsg>(new MyCallbackBase <TMsg>(this, new MyCallbackTime <TMsg>(callback).Handle, permissions, serializer ?? GetSerializer <TMsg>()), messageType);
 }
Example #57
0
 /// <summary>
 /// Creates a local message hook and hooks it.
 /// </summary>
 /// <param name="callback"></param>
 public LocalMessageHook(MessageCallback callback)
     : this()
 {
     this.MessageOccurred = callback;
     StartHook();
 }
Example #58
0
            int state;  // 0: created, 1: waiting, 2: signaled

            public AsyncWaiter(ReceiverLink link, MessageCallback callback)
            {
                this.link     = link;
                this.callback = callback;
            }
Example #59
0
		public NativeOpenSsl (bool isServer, bool debug, NativeOpenSslProtocol protocol)
		{
			this.isServer = isServer;
			this.enableDebugging = debug;
			this.protocol = protocol;

			readHandler = Read_internal;
			writeHandler = Write_internal;
			shutdownHandler = Shutdown_internal;

			if (debug)
				debug_callback = new DebugCallback (OnDebugCallback);

			message_callback = new MessageCallback (OnMessageCallback);

			handle = native_openssl_initialize (debug ? 1 : 0, protocol, debug_callback, message_callback);
			if (handle.IsInvalid)
				throw new ConnectionException ("Handle invalid.");

			var ret = native_openssl_create_context (handle, !isServer);
			CheckError (ret);
		}
Example #60
0
 /// <summary>
 /// Starts the message pump.
 /// </summary>
 /// <param name="credit">The link credit to issue. See <seealso cref="SetCredit(int, bool)"/> for more details.</param>
 /// <param name="onMessage">If specified, the callback to invoke when messages are received.
 /// If not specified, call Receive method to get the messages.</param>
 public void Start(int credit, MessageCallback onMessage = null)
 {
     this.onMessage = onMessage;
     this.SetCredit(credit, true);
 }