Beispiel #1
0
        private void SendCallback(IAsyncResult ar)
        {
            Connection.EndSend(ar);
            TransferArgs args = new TransferArgs(Connection, sndBuffer, sndBuffer.Length);

            Send?.Invoke(this, args);
        }
Beispiel #2
0
        private void SendToCallback(IAsyncResult ar)
        {
            int sentSize = Instance.EndSendTo(ar);

            TransferArgs args = new TransferArgs(Instance, sendBuffer, sentSize);

            Send?.Invoke(this, args);
        }
 /// <summary>
 /// Broadcast a message to all the connected clients.
 /// </summary>
 /// <param name="buffer">Data to broadcast</param>
 /// <param name="size">Size of the data</param>
 /// <param name="flags">Socket flags</param>
 public void BeginBroadcast(byte[] buffer, SocketFlags flags = SocketFlags.None)
 {
     foreach (Socket socket in Connections)
     {
         socket.Send(buffer);
         TransferArgs args = new TransferArgs(socket, buffer, buffer.Length);
         Broadcast?.Invoke(this, args);
     }
 }
        private void SendCallback(IAsyncResult ar)
        {
            Socket sock = (Socket)ar.AsyncState;

            sock.EndSend(ar);

            TransferArgs args = new TransferArgs(sock, sndBuffer, sndBuffer.Length);

            Send?.Invoke(this, args);
        }
Beispiel #5
0
        private void ReceiveCallback(IAsyncResult ar)
        {
            IPEndPoint ipe = IpEndpoint;

            byte[] receivedData = Listener.EndReceive(ar, ref ipe);
            IpEndpoint = ipe;

            TransferArgs args = new TransferArgs(Listener.Client, receivedData, receivedData.Length);

            Receive?.Invoke(this, args);
        }
Beispiel #6
0
        private void ReceiveCallback(IAsyncResult ar)
        {
            int receivedBytes = Connection.EndReceive(ar);

            if (receivedBytes > 0)
            {
                Connection.BeginReceive(rcvBuffer, 0, GeneralBufferSize, SocketFlags.None, (ReceiveCallback), Connection);

                TransferArgs args = new TransferArgs(Connection, rcvBuffer, receivedBytes);
                Receive?.Invoke(this, args);
            }
        }
Beispiel #7
0
        public void ProcessRecievedMessage(string payload)
        {
            var handler = OnTransferReceived;

            if (handler != null)
            {
                var msg = JsonConvert.DeserializeObject <TransferMessage>(payload);
                var arg = new TransferArgs {
                    Transfer = msg.Data
                };
                handler(this, arg);
            }
        }
Beispiel #8
0
        public static void GetAbiJsonToBin()
        {
            string       _code = "eosio.token", _action = "transfer", _memo = "";
            TransferArgs _args = new TransferArgs()
            {
                from = "yatendra1", to = "yatendra1", quantity = "1.0000 EOS", memo = _memo
            };
            var abiJsonToBin = chainAPI.GetAbiJsonToBin(_code, _action, _args);

            logger.Info("For code {0}, action {1}, args {2} and memo {3} recieved bin {4}", _code, _action, _args, _memo, abiJsonToBin.binargs);

            var abiBinToJson = chainAPI.GetAbiBinToJson(_code, _action, abiJsonToBin.binargs);

            logger.Info("Received args json {0}", JsonConvert.SerializeObject(abiBinToJson.args));
        }
Beispiel #9
0
        public static void TestTransaction()
        {
            string _accountName = "yatendra1", _accountNameTo = "yatendra1234", _permissionName = "active", _code = "eosio.token", _action = "transfer", _memo = "";
            //prepare arguments to be passed to action
            TransferArgs _args = new TransferArgs()
            {
                from = _accountName, to = _accountNameTo, quantity = "1.0000 EOS", memo = _memo
            };
            //BuyRamArgs _args = new BuyRamArgs(){ payer = _accountName, receiver = _accountName, quant = "0.001 EOS" };

            //prepare action object
            Action action = new ActionUtility(host).GetActionObject(_action, _accountName, _permissionName, _code, _args);

            List <string> privateKeysInWIF = new List <string> {
                privateKeyWIF
            };

            //push transaction
            var transactionResult = chainAPI.PushTransaction(new [] { action }, privateKeysInWIF);

            logger.Info(transactionResult.transaction_id);
        }
        private void ReceiveCallback(IAsyncResult ar)
        {
            Socket sock = (Socket)ar.AsyncState;

            int receivedBytes = 0;

            try
            {
                receivedBytes = sock.EndReceive(ar);
            }
            catch
            {
                sock.Close();
                Connections.Remove(sock);
                return;
            }

            TransferArgs args = new TransferArgs(sock, rcvBuffer, receivedBytes);

            Receive?.Invoke(this, args);
            sock.BeginReceive(rcvBuffer, 0, GeneralBufferSize, SocketFlags.None, (ReceiveCallback), sock);
        }