Пример #1
0
        /// <summary>
        /// 连接服务器
        /// </summary>
        /// <param name="callback">连接服务器回调</param>
        /// <param name="brokerID">经纪商代码</param>
        /// <param name="frontAddress">前置服务器地址,tcp://IP:Port</param>
        public void Connect(DataCallback callback, string brokerID, string frontAddress)
        {
            _api.BrokerID  = brokerID;
            _api.FrontAddr = frontAddress;

            AddCallback(callback, -1);
            _api.Connect();
        }
Пример #2
0
        public SequentialCommunication(SendData sendData, DataCallback callback)
        {
            this.sendData = sendData;
            this.callback = callback;

            sendingBuffer   = new Datagram[SEQUENCE_SIZE];
            receivingBuffer = new Datagram[SEQUENCE_SIZE];
        }
Пример #3
0
        public void TestCancelParkedOrder()
        {
            var insertParkedOrderCallback = new DataCallback <ParkedOrderInfo>((DataResult <ParkedOrderInfo> result) =>
            {
                ParkedOrderInfo pParkedOrder = new ParkedOrderInfo();
                pParkedOrder = result.Result;
                if (result.IsSuccess)
                {
                    var cancelParkedOrderCallback = new DataCallback <ParkedOrderInfo>((DataResult <ParkedOrderInfo> cancelParkedOrderResult) =>
                    {
                        pParkedOrder = cancelParkedOrderResult.Result;
                        if (cancelParkedOrderResult.IsSuccess)
                        {
                            Console.WriteLine("预埋撤单录入成功,ParkedOrderActionID:{0}", pParkedOrder.ParkedOrderActionID);
                        }
                        else
                        {
                            Console.WriteLine("预埋撤单录入失败:{0}", cancelParkedOrderResult.Error);
                        }
                        Assert.IsTrue(cancelParkedOrderResult.IsSuccess);
                    });
                    CancelOrderParameter fieldAction = new CancelOrderParameter();
                    fieldAction.ActionFlag           = ActionFlag.Delete;
                    fieldAction.InstrumentID         = pParkedOrder.InstrumentID;
                    fieldAction.OrderRef             = pParkedOrder.OrderRef;
                    fieldAction.ExchangeID           = pParkedOrder.ExchangeID;
                    fieldAction.OrderSysID           = new string('\0', 21 - pParkedOrder.OrderSysID.Length) + pParkedOrder.OrderSysID;

                    _adapter.CancelParkedOrder(cancelParkedOrderCallback, fieldAction);
                    Thread.Sleep(50);
                }
                else
                {
                    Console.WriteLine("预埋单录入失败:", result.Error);
                }
                Assert.IsTrue(result.IsSuccess);
            });
            OrderParameter field = new OrderParameter();

            field.InstrumentID        = "TF1809";
            field.OrderRef            = "1";
            field.Direction           = DirectionType.Buy;
            field.PriceType           = OrderPriceType.LimitPrice;
            field.OpenCloseFlag       = OpenCloseFlag.Open;
            field.HedgeFlag           = HedgeFlag.Speculation;
            field.Price               = 97.010M;
            field.Quantity            = 1;
            field.TimeCondition       = TimeConditionType.GFD;
            field.VolumeCondition     = VolumeConditionType.AV;
            field.MinVolume           = 1;
            field.ContingentCondition = ContingentConditionType.Immediately;
            field.ForceCloseReason    = ForceCloseReasonType.NotForceClose;
            field.IsAutoSuspend       = 0;
            field.UserForceClose      = 0;

            _adapter.InsertParkedOrder(insertParkedOrderCallback, field);
            Thread.Sleep(200);
        }
Пример #4
0
    public static void Query(string query, int limit, int callbacksPerFrame, DataCallback dataCallback, FinishCallback finishCallback)
    {
        string queryString = string.Format("?query={1}&limit={2}", baseurl, UnityWebRequest.EscapeURL(query), limit);
        // queryString = UnityWebRequest.EscapeURL(queryString); // escape query for crossorigin.me
        string url = baseurl + queryString;

        Debug.Log(url);
        instance.StartCoroutine(QueryRoutine(url, callbacksPerFrame, dataCallback, finishCallback));
    }
Пример #5
0
  void Awake () {
    Debug.Log("testing callbacks on object:" + gameObject.GetHashCode());

    // during the course of this call into the plugin, it will call back the _onetime_callback() function.
    // because the plugin call/marshaling layer retains a reference to the SimpleCallback delegate, it
    // can not be freed or GC'd during the call
    // all of the following syntaxes work:
    // 1. reply_during_call(new SimpleCallback(this._onetime_callback));
    // 2. reply_during_call(this._onetime_callback);
    // 3. below, the most clear form
    reply_during_call(_onetime_callback);

    // to pass a delegate that is called after the call into the plugin completes, either later
    // or repeatedly later, you have to retain the delegate, which you can only do by holding
    // it in a wider-scope, in this case in a private member/ivar. the marshaling layer will
    // add a hold/addref/retain to the delegate during the call and release it on return, so
    // unless you are holding on to it the plugin would be left with an invalid pointer as
    // soon as GC runs. it's worth understanding that the delegate is effectively two "objects":
    // a managed object in C# which may move due to GC which is holding onto a fixed
    // (possibly unmanaged - that's runtime-dependent) function-pointer which is what the
    // plugin can refer to. GC may move the managed C# object around, but the function pointer
    // in the native-code plugin remains immobile.
    _recurring_callback_holder = new SimpleCallback(_recurring_callback);
    set_recurring_reply(gameObject.GetHashCode(), _recurring_callback_holder);

    // this is a one-time data-polling call to pull bytes from native/unmanaged code.
    // the difficulty with a poll API is that the plugin cannot allocate memory for the
    // caller easily unless both sides agree how it is going to be released. a polling
    // API can be useful if you have a native data structure or very long-lived buffer
    // associated with the specific object instance that Unity can depend on not moving
    // or disappearing. alternately you can force the caller to deallocate the memory
    // returned from the poll. as with any real-time system, though, you want to make
    // sure you are minimizing data copies (and conversions), so think through the
    // memory lifetimes carefully.
    IntPtr buffer=IntPtr.Zero, length=IntPtr.Zero;
    poll_data(gameObject.GetHashCode(), out buffer, out length);
    if (buffer != IntPtr.Zero && length != IntPtr.Zero) {
      int len = length.ToInt32();
      byte[] data = new byte[len];
      Marshal.Copy(buffer, data, 0, len);
      Debug.Log("polled " + len + " bytesinto C# as " + data);
    }

    // this recurring callback, like the SimpleCallback, must be held longer than the
    // duration of the call. this example is to demonstrate a common requirement: passing
    // data between a native/unmanaged plugin C#. in this case the native plugin pushes
    // raw bytes of data into a C# byte[], which is a nice way to control the lifetime
    // of the data on the plugin's side - by the time the callback returns the plugin
    // knows Unity/C# has no further access, they should have copied what they needed.
    // this form of "push" API's where the native side buffers data and pushes it to
    // Unity/C# and the C# side also buffers and uses and frees it on its own schedule
    // is a pretty safe design which can minimize the total number of data copies
    // and problems with memory leaks.
    _recurring_data_push_holder = new DataCallback(_recurring_data_push);
    set_recurring_data_push(gameObject.GetHashCode(), _recurring_data_push_holder);
  }
Пример #6
0
 public void AddDataCallback(string address, DataCallback callback)
 {
     lock (_delegatesLock)
     {
         if (_dataCallbackMap.ContainsKey(address))
             _dataCallbackMap[address] += callback;
         else
             _dataCallbackMap[address] = callback;
     }
 }
Пример #7
0
 public void RemoveDataCallback(string address, DataCallback callback)
 {
     lock (_delegatesLock)
     {
         var temp = _dataCallbackMap[address] - callback;
         if (temp != null)
             _dataCallbackMap[address] = temp;
         else
             _dataCallbackMap.Remove(address);
     }
 }
Пример #8
0
 /// <summary>
 /// Loads data asyncroniously.
 /// Handles Loading and decryption, will invoke the given callback when done
 /// </summary>
 /// <param name="path">Relative path to the data folder.</param>
 /// <param name="callback">Callback to execute when done.</param>
 public void LoadDataAsync(string path, DataCallback callback)
 {
     if (!encryptionLoaded)
     {
         callbacks.Enqueue(new KeyValuePair <string, DataCallback>(path, callback));
     }
     else
     {
         LoadDataAsyncFromDisc(path, callback);
     }
 }
Пример #9
0
 public void ReadLiveAsync(DataCallback callback)
 {
     ReadHttp(out var task);
     task.GetAwaiter().OnCompleted(delegate
     {
         var awaiter = task.Result.Content
                       .ReadAsStringAsync()
                       .GetAwaiter();
         awaiter.OnCompleted(delegate { callback(ReadValue(awaiter.GetResult())); });
     });
 }
Пример #10
0
    public void GetData(DataCallback callback)
    {
        this.callback = callback;

        var serverRequestForm = new WWWRequestForm();

        AddDefaultToServerRequestForm(serverRequestForm);

        var serverRequest = new WWWRequest(monoBehaviour, methodServerUrl, serverRequestForm);

        monoBehaviour.StartCoroutine(RequestData(serverRequest));
    }
Пример #11
0
        public static void GetData(DataType dataType, DataCallback callback, bool highPrio = false)
        {
            KeyValuePair <DataType, DataCallback> dataRequest = new KeyValuePair <DataType, DataCallback>(dataType, callback);

            if (highPrio)
            {
                DataRequests.AddFirst(dataRequest);
            }
            else
            {
                DataRequests.AddLast(dataRequest);
            }
        }
Пример #12
0
        public void Communicating(double packetLoss)
        {
            Queue <uint> vals   = new Queue <uint>(chance.N(1000, () => (uint)chance.Natural()));
            Queue <uint> toSend = new Queue <uint>(vals);

            SequentialCommunication comm1 = null;
            SequentialCommunication comm2 = null;

            Action <SequentialCommunication, byte[]> trySend = (comm, data) =>
            {
                if (chance.Bool(1 - packetLoss))
                {
                    new Thread(() =>
                    {
                        Thread.Sleep(20);
                        comm.Received(data);
                    }).Start();
                }
            };

            Action <uint, byte[]> verify = (expected, data) =>
            {
                uint recv = BitConverter.ToUInt32(data.ToLength(4), 0);
                Assert.AreEqual(expected, recv);
            };

            SendData send1 = (data) =>
            {
                trySend(comm2, data);
            };

            SendData send2 = (data) =>
            {
                trySend(comm1, data);
            };

            DataCallback callback2 = (data) =>
            {
                verify(vals.Dequeue(), data);
            };

            comm1 = new SequentialCommunication(send1, null);
            comm2 = new SequentialCommunication(send2, callback2);

            for (int i = 0; i < vals.Count; i++)
            {
                byte[] data = BitConverter.GetBytes(toSend.Dequeue());
                comm1.Send(data);
            }
        }
Пример #13
0
        public void TestCancelOrder()
        {
            var insertOrderCallback = new DataCallback <OrderInfo>((DataResult <OrderInfo> result) =>
            {
                OrderInfo orderInfo = new OrderInfo();
                orderInfo           = result.Result;
                if (result.IsSuccess)
                {
                    var cancelOrderCallback = new DataCallback <OrderInfo>((DataResult <OrderInfo> cancelOrderResult) =>
                    {
                        orderInfo = cancelOrderResult.Result;
                        if (cancelOrderResult.IsSuccess)
                        {
                            Console.WriteLine("撤单成功,OrderRef:{0}, InstrumentID:{1}", orderInfo.OrderRef, orderInfo.InstrumentID);
                        }
                        Assert.IsTrue(cancelOrderResult.IsSuccess);
                    });
                    CancelOrderParameter field = new CancelOrderParameter();
                    field.ActionFlag           = ActionFlag.Delete;
                    field.InstrumentID         = "TF1809";
                    field.OrderRef             = orderInfo.OrderRef;
                    field.ExchangeID           = orderInfo.ExchangeID;
                    field.OrderSysID           = new string('\0', 21 - orderInfo.OrderSysID.Length) + orderInfo.OrderSysID;

                    _adapter.CancelOrder(cancelOrderCallback, field);
                    Thread.Sleep(50);
                }
                Assert.IsTrue(result.IsSuccess);
            });
            OrderParameter order = new OrderParameter();

            order.InstrumentID        = "TF1809";
            order.OrderRef            = "1";
            order.Direction           = DirectionType.Buy;
            order.PriceType           = OrderPriceType.LimitPrice;
            order.OpenCloseFlag       = OpenCloseFlag.Open;
            order.HedgeFlag           = HedgeFlag.Speculation;
            order.Price               = 97.270M;
            order.Quantity            = 1;
            order.TimeCondition       = TimeConditionType.GFD;
            order.VolumeCondition     = VolumeConditionType.AV;
            order.MinVolume           = 1;
            order.ContingentCondition = ContingentConditionType.Immediately;
            order.ForceCloseReason    = ForceCloseReasonType.NotForceClose;
            order.IsAutoSuspend       = 0;
            order.UserForceClose      = 0;

            _adapter.InsertOrder(insertOrderCallback, order);
            Thread.Sleep(200);
        }
Пример #14
0
        public void TestQueryAccount()
        {
            var queryAccountCallback = new DataCallback <AccountInfo>((DataResult <AccountInfo> result) =>
            {
                if (result.IsSuccess)
                {
                    Console.WriteLine("帐户资金查询成功, Available:{0}", result.Result.Available);
                }
                Assert.IsTrue(result.IsSuccess);
            });

            _adapter.QueryAccount(queryAccountCallback);
            Thread.Sleep(100);
        }
Пример #15
0
        public void TestQueryInvestor()
        {
            var queryInvestorInfoCallback = new DataCallback <InvestorInfo>((DataResult <InvestorInfo> result) =>
            {
                if (result.IsSuccess)
                {
                    Console.WriteLine("投资者查询成功,InvestorID:{0}", result.Result.InvestorID);
                }
                Assert.IsTrue(result.IsSuccess);
            });

            _adapter.QueryInvestor(queryInvestorInfoCallback);
            Thread.Sleep(100);
        }
Пример #16
0
 public void AddDataCallback(string address, DataCallback callback)
 {
     lock (_delegatesLock)
     {
         if (_dataCallbackMap.ContainsKey(address))
         {
             _dataCallbackMap[address] += callback;
         }
         else
         {
             _dataCallbackMap[address] = callback;
         }
     }
 }
Пример #17
0
    static IEnumerator QueryRoutine(string url, int callbacksPerFrame, DataCallback dataCallback, FinishCallback finishCallback)
    {
        busy = true;
        var request = UnityWebRequest.Get(url);

        yield return(request.SendWebRequest());

        if (!request.isNetworkError)
        {
            string json = request.downloadHandler.text;
            int    i    = 0;
            foreach (Match m in Regex.Matches(json, @"(\{[^\}]*\})"))
            {
                Data data = null;
                try {
                    data = JsonUtility.FromJson <Data>(m.ToString());
                } catch (System.ArgumentException e) {
                    Debug.LogErrorFormat("Error parsing JSON data {0}: {1}", i, e);
                }
                if (data != null)
                {
                    if (data.a <= 0)
                    {
                        Debug.LogErrorFormat("Invalid JSON data {0}: Invalid Semimajor Axis of {1} AU", i, data.a);
                    }
                    else if (data.e < 0 || data.e >= 1)
                    {
                        Debug.LogErrorFormat("Invalid JSON data {0}: Invalid Eccentricity of {1}", i, data.e);
                    }
                    else
                    {
                        data.index = i;
                        dataCallback(data);
                    }
                }
                if (i % callbacksPerFrame == 0)
                {
                    yield return(null);
                }
                i++;
            }
            finishCallback();
        }
        else
        {
            Debug.LogError(request.error);
        }
        busy = false;
    }
Пример #18
0
 public void RemoveDataCallback(string address, DataCallback callback)
 {
     lock (_delegatesLock)
     {
         var temp = _dataCallbackMap[address] - callback;
         if (temp != null)
         {
             _dataCallbackMap[address] = temp;
         }
         else
         {
             _dataCallbackMap.Remove(address);
         }
     }
 }
Пример #19
0
        public void ReceivingFragmented()
        {
            SequentialCommunication comm;

            uint next = 0;

            DataCallback callback = (data) =>
            {
                Debug(data);

                uint received = BitConverter.ToUInt32(data, 0);

                Console.WriteLine(received);

                Assert.AreEqual(next, received);
                next++;
            };

            comm = new SequentialCommunication(null, callback);

            Func <uint, byte, byte[], byte[]> genDgram = (seq, frag, data) =>
            {
                byte[] sequence = BitConverter.GetBytes(seq)
                                  .ToLength(SequentialCommunication.SequenceBytes);

                byte[] toSend = sequence.Append(frag).Append(data);

                Debug(toSend);

                return(toSend);
            };

            Action <uint, byte, uint> send = (seq, frag, data) =>
            {
                byte[] dgram = genDgram(seq, frag, BitConverter.GetBytes(data).ToLength(4));
                comm.Received(dgram);
            };

            send(0, 0, 0);
            send(1, 1, 1);
            send(3, 1, 2);
            send(5, 0, 3);
            send(4, 0, 0);
            send(2, 0, 0);

            Assert.AreEqual(4, next);
        }
Пример #20
0
        public void TestUpdateUserPassword()
        {
            var updUserPasswCallback = new DataCallback((DataResult result) =>
            {
                if (result.IsSuccess)
                {
                    Console.WriteLine("更新用户口令成功");
                }
                Assert.IsFalse(result.IsSuccess);
            });
            string newPassword = "******";

            _adapter.UpdateUserPassword(updUserPasswCallback, _password, newPassword);
            Thread.Sleep(100);
            _adapter.UpdateUserPassword(updUserPasswCallback, newPassword, _password);
            Thread.Sleep(100);
        }
Пример #21
0
        public int Init(Action <byte, DolphiimoteData> newData, Action <byte, bool> wiimoteConnectionChanged, Action <byte, DolphiimoteCapabilities> capabilitiesChanged, Action <string> newLogMessage)
        {
            dataCallback         = (wiimote, data, user) => newData(wiimote, MarshalType <DolphiimoteData>(data));
            capabilitiesCallback = (wiimote, capabilities, user) => capabilitiesChanged(wiimote, MarshalType <DolphiimoteCapabilities>(capabilities));
            connectionCallback   = (wiimote, status) => wiimoteConnectionChanged(wiimote, Convert.ToBoolean(status));
            logCallback          = (str, length) => newLogMessage(Marshal.PtrToStringAnsi(str, (int)length));

            var callbacks = new DolphiimoteCallbacks
            {
                dataReceived        = MarshalFunction(dataCallback),
                capabilitiesChanged = MarshalFunction(capabilitiesCallback),
                connectionChanged   = MarshalFunction(connectionCallback),
                onLog    = MarshalFunction(logCallback),
                userData = IntPtr.Zero
            };

            return(dolphiimoteInit(callbacks));
        }
Пример #22
0
    public void recv(DataCallback cb)
    {
        if (mSocket == null)
        {
            return;
        }

        if (!mSocket.Poll(0, SelectMode.SelectRead))
        {
            return;
        }

        int rcvlen = 0;

        try
        {
            rcvlen = mSocket.Receive(mBuffRecv);
        }
        catch (System.Exception)
        {
            rcvlen = -1;
        }

        if (rcvlen <= 0)
        {
            close();
            return;
        }
        else
        {
            mBytesRecv += rcvlen;
        }

        Buffer.BlockCopy(mBuffRecv, 0, mBuffLeft, mLeftDataPos, rcvlen);
        mLeftDataPos += rcvlen;

        byte[] left = cb(mBuffLeft, mLeftDataPos);
        mLeftDataPos = 0;
        if (left != null)
        {
            Buffer.BlockCopy(left, 0, mBuffLeft, 0, left.Length);
            mLeftDataPos = left.Length;
        }
    }
Пример #23
0
        public void Fragmentation(double packetLoss)
        {
            byte[][] buffer = TestBuffer(size: 10, datagramMin: 1000, datagramMax: 5000);

            int exp = 0;
            SequentialCommunication comm1 = null;
            SequentialCommunication comm2 = null;

            Action <SequentialCommunication, byte[]> trySend = (comm, data) =>
            {
                if (chance.Bool(1 - packetLoss))
                {
                    new Thread(() => comm.Received(data)).Start();
                }
            };

            DataCallback callback = (data) =>
            {
                CollectionAssert.AreEqual(buffer[exp++], data);
            };

            SendData send1 = (data) =>
            {
                trySend(comm2, data);
            };

            SendData send2 = (data) =>
            {
                trySend(comm1, data);
            };

            comm1 = new SequentialCommunication(send1, null);
            comm2 = new SequentialCommunication(send2, callback);

            for (int i = 0; i < buffer.Length; i++)
            {
                byte[] data = buffer[i];
                comm1.Send(data);
            }
        }
Пример #24
0
        public unsafe int Init(DataCallback data, ErrorCallback error, string url, bool hw, string ffmepgPath)
        {
            if (string.IsNullOrEmpty(url))
            {
                return(-1);
            }
            Url = url;

            Hw = hw;

            if (string.IsNullOrEmpty(ffmepgPath))
            {
                return(-1);
            }
            FFmpegBinaryPath = ffmepgPath;

            if (data == null)
            {
                return(-1);
            }
            dataCallback = data;

            if (error == null)
            {
                return(-1);
            }
            errorCallback = error;

            if (Directory.Exists(FFmpegBinaryPath))
            {
                ffmpeg.RootPath = FFmpegBinaryPath;
            }
            else
            {
                error($"Could not find FFmpeg binaries in {FFmpegBinaryPath}");
                return(-1);
            }

            return(0);
        }
Пример #25
0
        public static unsafe void LockDaPic(Bitmap img, DataCallback callback)
        {
            BitmapData bData = img.LockBits(new Rectangle(0, 0, img.Width, img.Height), ImageLockMode.ReadWrite, img.PixelFormat);

            byte bitsPerPixel = (byte)Image.GetPixelFormatSize(img.PixelFormat);
            //RGB == 24 bits
            //ARGB == 32 bits

            byte *scan0 = (byte *)bData.Scan0.ToPointer();

            for (int y = 0; y < bData.Height; y++)
            {
                for (int x = 0; x < bData.Width; x++)
                {
                    byte *data = scan0 + y * bData.Stride + x * bitsPerPixel / 8;

                    callback(x, y, data);//optional callback
                }
            }

            img.UnlockBits(bData);//unlock from memory
        }
Пример #26
0
        public void Receiving()
        {
            SequentialCommunication comm;

            uint next = 0;

            DataCallback callback = (data) =>
            {
                uint received = BitConverter.ToUInt32(data, 0);

                Assert.AreEqual(next, received);
                next++;
            };

            comm = new SequentialCommunication(null, callback);

            Func <uint, byte[], byte[]> genDgram = (seq, data) =>
            {
                byte[] sequence = BitConverter.GetBytes(seq)
                                  .ToLength(SequentialCommunication.SequenceBytes);

                return(sequence.Append(0).Append(data));
            };

            Action <uint, uint> send = (seq, data) =>
            {
                byte[] dgram = genDgram(seq, BitConverter.GetBytes(data).ToLength(4));
                comm.Received(dgram);
            };

            send(0, 0);
            send(1, 1);
            send(2, 2);
            send(5, 5);
            send(3, 3);
            send(1, 1);
            send(4, 4);
        }
Пример #27
0
 /// <summary>
 /// Create a MessageLogger and register the callback function
 /// </summary>
 /// <param name="logLevel">The log level.</param>
 public DataLogger(int logLevel)
 {
     _ptr     = DataLoggerCreate(logLevel);
     _handler = DataHandler;
     DataLoggerRegisterCallback(_ptr, _handler);
 }
Пример #28
0
 private static extern void DataLoggerRegisterCallback(
     IntPtr logger,
     DataCallback messageCallback);
Пример #29
0
        void gitCommand_DataReceived(object sender, DataReceivedEventArgs e)
        {
            if (e.Data == null)
                return;

            if (e.Data.Contains("%") || e.Data.StartsWith("remote: Counting objects"))
            {
                if (ProgressBar.InvokeRequired)
                {
                    // It's on a different thread, so use Invoke.
                    DataCallback d = new DataCallback(SetProgress);
                    this.Invoke(d, new object[] { e.Data });
                } else
                {
                    SetProgress(e.Data);
                }
            } else
            {
                /*if (Output.InvokeRequired)
                {
                    // It's on a different thread, so use Invoke.
                    DataCallback d = new DataCallback(AddOutput);
                    this.Invoke(d, new object[] { e.Data });
                } else
                {
                    AddOutput(e.Data);
                }*/
                outputString.Append(e.Data);
                outputString.Append("\n");
            }

            if (Plink)
            {
                if (e.Data.StartsWith("If you trust this host, enter \"y\" to add the key to"))
                {
                    if (MessageBox.Show("The fingerprint of this host is not registered by PuTTY.\nThis causes this process to hang, and that why it is automaticly stopped.\n\nWhen te connection is opened detached from Git and GitExtensions, the host's fingerprint can be registered.\nYou could also manually add the host's fingerprint or run Test Connection from the remotes dialog.\n\nDo you want to register the host's fingerprint and restart the process?", "Host Fingerprint not registered", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        string remoteUrl = GitCommands.GitCommands.GetSetting("remote." + Remote + ".url");

                        if (string.IsNullOrEmpty(remoteUrl))
                            GitCommands.GitCommands.RunRealCmd("cmd.exe", "/k \"\"" + GitCommands.Settings.Plink + "\" " + Remote + "\"");
                        else
                            GitCommands.GitCommands.RunRealCmd("cmd.exe", "/k \"\"" + GitCommands.Settings.Plink + "\" " + remoteUrl + "\"");

                        restart = true;
                    }

                    try
                    {
                        gitCommand.Process.Kill();
                    }
                    catch
                    {
                    }
                }
            }
        }
 /// <summary>
 /// Create a MessageLogger and register the callback function
 /// </summary>
 /// <param name="logLevel">The log level.</param>
 public DataLogger(int logLevel)
 {
     _ptr = DataLoggerCreate(logLevel);
      _handler = DataHandler;
      DataLoggerRegisterCallback(_ptr, _handler);
 }
Пример #31
0
 void OnApplicationQuit() {
   set_recurring_reply(gameObject.GetHashCode(), null);
   _recurring_callback_holder = null;
   set_recurring_data_push(gameObject.GetHashCode(), null);
   _recurring_data_push_holder = null;
 }
Пример #32
0
 void OnDestroy() {
   set_recurring_reply(gameObject.GetHashCode(), null);
   _recurring_callback_holder = null;
   set_recurring_data_push(gameObject.GetHashCode(), null);
   _recurring_data_push_holder = null;
 }
Пример #33
0
 private static extern void set_recurring_data_push(int objectHash, DataCallback callback);
Пример #34
0
		private void InitializeAsyncMode()
		{
			if(@group == null)
				throw new ObjectDisposedException("Group");
			if(asyncIO == null || connectionPointContainer == null)
				throw new NotSupportedException();

			if (asyncCallback != null)
				return;

            var dataCallbackId = new Guid("39c13a70-011e-11d0-9675-0020afd8adb3");
            IConnectionPoint point;
            connectionPointContainer.FindConnectionPoint(ref dataCallbackId, out point);
            if (point == null)
                throw new NotSupportedException();

			var callback = new DataCallback(this);
            point.Advise(callback, out asyncCookie);

			asyncCallback = callback;
            connectionPoint = point;
		}
Пример #35
0
        private int Raise(DataCallback cb, Parser p, ByteBuffer buf, int pos, int len)
        {
            if (cb == null || pos == -1)
                return 0;

            try {
                return cb (p,buf,pos,len);
            } catch (System.Exception e) {
                Console.WriteLine (e);

                RaiseOnError (p, e.Message, buf, pos);
                return -1;
            }
        }
 private static extern void DataLoggerRegisterCallback(
  IntPtr logger,
  DataCallback messageCallback);
Пример #37
0
 private void SaveData(DataCallback cb, int id, byte[] data)
 {
     lock (_EvenQueue)
         _EvenQueue.Enqueue(new DataTask(cb, id, data));
 }
Пример #38
0
 static extern void UF_SetReceiveDataPacketCallback(DataCallback callback);
Пример #39
0
 private static extern void set_recurring_data_push(int objectHash, DataCallback callback);
Пример #40
0
 static extern Int32 S2253_RegisterCallback(DataCallback cb, Int32 devid, Int32 strmidx);
Пример #41
0
 public DataTask(DataCallback cb, int id, byte[] data)
 {
     _Callback = cb;
     _PacketId = id;
     _Content  = data;
 }
Пример #42
0
        void gitCommand_DataReceived(object sender, DataReceivedEventArgs e)
        {
            if (e.Data == null)
                return;

            if (e.Data.Contains("%"))
            {
                if (ProgressBar.InvokeRequired)
                {
                    // It's on a different thread, so use Invoke.
                    DataCallback d = new DataCallback(SetProgress);
                    this.Invoke(d, new object[] { e.Data });
                } else
                {
                    SetProgress(e.Data);
                }
            } else
            {
                /*if (Output.InvokeRequired)
                {
                    // It's on a different thread, so use Invoke.
                    DataCallback d = new DataCallback(AddOutput);
                    this.Invoke(d, new object[] { e.Data });
                } else
                {
                    AddOutput(e.Data);
                }*/
                outputString.Append(e.Data);
                outputString.Append("\n");
            }
        }