示例#1
0
 public void CollectState(NetStream stream)
 {
     if (showDebug)
     {
         Debug.Log(base.name + " CollectState ");
     }
     NetBoolEncoder.CollectState(stream, shattered);
 }
示例#2
0
        } // ReadFirstLine

        private void SendContinue()
        {
            // Output:
            // HTTP/1.1 100 Continue

            // Send the continue response back to the client
            NetStream.Write(_bufferhttpContinue, 0, _bufferhttpContinue.Length);
        } // SendContinue
 public void ApplyState(NetStream state)
 {
     if (showDebug)
     {
         Debug.Log(base.name + " ApplyState ");
     }
     targetHeat = ((!NetBoolEncoder.ApplyState(state)) ? 0f : 0.9f);
 }
 public void ApplyLerpedState(NetStream state0, NetStream state1, float mix)
 {
     if (showDebug)
     {
         Debug.Log(base.name + " ApplyLerpedState ");
     }
     targetHeat = ((!NetBoolEncoder.ApplyLerpedState(state0, state1, mix)) ? 0f : 0.9f);
 }
示例#5
0
    private void OnReadInstantiate(NetStream stream)
    {
        Vector3 pos = stream.ReadVector3();
        string  id  = stream.ReadString();

        transform.position = pos;
        character.id       = id;
    }
 public void CalculateDelta(NetStream state0, NetStream state1, NetStream delta)
 {
     if (showDebug)
     {
         Debug.Log(base.name + " Calc Data ");
     }
     NetBoolEncoder.CalculateDelta(state0, state1, delta);
 }
示例#7
0
        public static QueueAck ReadAckStream(NetworkStream stream, int ReadTimeout, int ReceiveBufferSize = 8192)
        {
            NetStream netstream = new NetStream();

            //netstream.CopyWithTerminateCount(stream, ProcessTimeout, ReceiveBufferSize);
            netstream.CopyFrom(stream, ReadTimeout, ReceiveBufferSize);
            return(new QueueAck(netstream));
        }
 public void CollectState(NetStream stream)
 {
     if (showDebug)
     {
         Debug.Log(base.name + " CollectState ");
     }
     NetBoolEncoder.CollectState(stream, targetHeat > 0f);
 }
 public void ApplyLerpedState(NetStream state0, NetStream state1, float mix)
 {
     if (showDebug)
     {
         Debug.Log(base.name + " Apply Lerp ");
     }
     ApplyState(NetBoolEncoder.ApplyLerpedState(state0, state1, mix));
 }
 public void ApplyState(NetStream state)
 {
     if (showDebug)
     {
         Debug.Log(base.name + " Net State ");
     }
     ApplyState(NetBoolEncoder.ApplyState(state));
 }
 private void OnFail(NetStream stream)
 {
     if (showDebug)
     {
         Debug.Log(base.name + " Fail ");
     }
     FailStart();
 }
 public void CollectState(NetStream stream)
 {
     if (showDebug)
     {
         Debug.Log(base.name + " Collect State ");
     }
     NetBoolEncoder.CollectState(stream, output.value >= 0.5f);
 }
 private void AddRequest(NetStream stream, NetRequest <ulong> request, NetConnection connection)
 {
     if (!connection.IsPeer && !connection.IsServer)
     {
         return;
     }
     request.Result = Add(stream);
 }
        public override void Handle(NetStream stream, Command command)
        {
            var str = serverObj.GetDeviceAddress(command);
            var bs  = System.Text.Encoding.UTF8.GetBytes(str);

            stream.Write(bs.Length);
            stream.Write(bs, bs.Length);
        }
示例#15
0
 public void ApplyLerpedState(NetStream state0, NetStream state1, float mix)
 {
     position = Mathf.Lerp(minValue, maxValue, encoder.ApplyLerpedState(state0, state1, mix));
     speed    = 0f;
     SetStatic(position);
     motor.SetValue(NetSignal.encoder.ApplyLerpedState(state0, state1, mix));
     velocity.SetValue(NetSignal.encoder.ApplyLerpedState(state0, state1, mix));
 }
 public void AddDelta(NetStream state0, NetStream delta, NetStream result)
 {
     if (showDebug)
     {
         Debug.Log(base.name + " Add Delta ");
     }
     NetBoolEncoder.AddDelta(state0, delta, result);
 }
示例#17
0
 public void CollectState(NetStream stream)
 {
     if (showDebug)
     {
         Debug.Log(base.name + " Collect State ");
     }
     stream.WriteNetId((connectedSocket != null) ? connectedSocket.sceneId : 0u);
 }
示例#18
0
    private void WriteOwnerData(NetStream stream)
    {
        string s = LoginServer.GetAccount(View.Controllers[0].Endpoint).baseModel;

        stream.WriteString(s);
        stream.WriteVector3(transform.position);
        stream.WriteString(character.id);
    }
示例#19
0
    public static void ItemSerializer(NetStream stream, object instance)
    {
        IInvItem item = (IInvItem)instance;

        stream.WriteUInt(item.DbId);
        stream.WriteInt(item.Quantity);
        item.WriteAdditional(stream);
    }
示例#20
0
 public void ApplyState(NetStream state)
 {
     position = Mathf.Lerp(minValue, maxValue, encoder.ApplyState(state));
     speed    = 0f;
     SetStatic(position);
     motor.SetValue(NetSignal.encoder.ApplyState(state));
     velocity.SetValue(NetSignal.encoder.ApplyState(state));
 }
示例#21
0
        /// <summary>
        /// Разорвать соединение
        /// </summary>
        public void Disconnect()
        {
            try { NetStream.Close(); }
            catch { }

            try { TcpClient.Close(); }
            catch { }
        }
示例#22
0
        private bool submit_course_data(string course_id)
        {
            var url = get_session_url() + "/xf_xsqxxxk.aspx?xh=" + username.Text + "&gnmkdm=N121103";

            debug_output("发送选课请求");
            string course_time = "", course_name = "";

            Invoke(new ThreadStart(delegate
            {
                course_time = courseTime.Text;
                course_name = courseName.Text;
            }));

            var post_param = new Parameters();

            post_param.Add("__EVENTTARGET", "");
            post_param.Add("__EVENTARGUMENT", "");
            post_param.Add("__VIEWSTATE", __VIEWSTATE);
            post_param.Add("ddl_kcxz", "");
            post_param.Add("ddl_ywyl", "");
            post_param.Add("ddl_kcgs", "");
            post_param.Add("ddl_xqbs", 2);
            post_param.Add("ddl_sksj", "");
            post_param.Add("TextBox1", "");
            post_param.Add("dpkcmcGrid:txtChoosePage", 1);
            post_param.Add("dpkcmcGrid:txtPageSize", 200);
            post_param.Add(course_id, "on");
            post_param.Add("Button1", "++提交++");

            var post_data = Encoding.UTF8.GetBytes(post_param.BuildQueryString());


            //response_sr.Close();
            var ns     = new NetStream();
            var header = new Parameters();

            header.Add("Origin", get_origin_url());
            header.Add("Referer", url);
            try
            {
                ns.HttpPost(url, post_data, NetStream.DEFAULT_CONTENT_TYPE_PARAM, header);
                if (ns.HTTP_Response.StatusCode != System.Net.HttpStatusCode.OK)
                {
                    debug_output("HTTP错误:服务器返回" + (int)ns.HTTP_Response.StatusCode + "(" + ns.HTTP_Response.StatusDescription + ")");
                    return(false); //status check
                }
                var response_str = ns.ReadResponseString(Encoding.Default);
                return(check_course_selected(response_str.Replace("\r", "").Replace("\n", "")));
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                ns.Close();
            }
        }
示例#23
0
        private async Task ReceiveMessageLoop()
        {
            try
            {
                var stableBuffer = new byte[16];
                var buffer       = new byte[4096];
                while (this.Connected)
                {
                    await NetStream.ReadBAsync(stableBuffer, 0, 16);

                    var protocol = DanmakuProtocol.FromBuffer(stableBuffer);
                    if (protocol.PacketLength < 16)
                    {
                        throw new NotSupportedException("协议失败: (L:" + protocol.PacketLength + ")");
                    }
                    var payloadlength = protocol.PacketLength - 16;
                    if (payloadlength == 0)
                    {
                        continue;
                    }
                    buffer = new byte[payloadlength];
                    await NetStream.ReadBAsync(buffer, 0, payloadlength);

                    if (protocol.Version == 2 && protocol.Action == 5)
                    {
                        using (var ms = new MemoryStream(buffer, 2, payloadlength - 2))
                            using (var deflate = new DeflateStream(ms, CompressionMode.Decompress))
                            {
                                var headerbuffer = new byte[16];
                                try
                                {
                                    while (true)
                                    {
                                        await deflate.ReadBAsync(headerbuffer, 0, 16);

                                        var protocol_in = DanmakuProtocol.FromBuffer(headerbuffer);
                                        payloadlength = protocol_in.PacketLength - 16;
                                        var danmakubuffer = new byte[payloadlength];
                                        await deflate.ReadBAsync(danmakubuffer, 0, payloadlength);

                                        ProcessDanmaku(protocol.Action, danmakubuffer);
                                    }
                                }
                                catch { }
                            }
                    }
                    else
                    {
                        ProcessDanmaku(protocol.Action, buffer);
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.Instance.LogError("ReceiveMessageLoop", ex);
                Disconnect();
            }
        }
示例#24
0
        public override void Launch(Response response, dynamic args)
        {
            string programPath = getString(args, "program");

            if (programPath == null)
            {
                SendErrorResponse(response, 3001, "Property 'program' is missing or empty.", null);
                return;
            }
            programPath = ConvertClientPathToDebugger(programPath);
            if (!File.Exists(programPath) && !Directory.Exists(programPath))
            {
                SendErrorResponse(response, 3002, "Program '{path}' does not exist.", new { path = programPath });
                return;
            }
            _t_work_dir = Path.GetDirectoryName(programPath);

            _t_main_file  = programPath;
            _t_main_lines = File.ReadAllLines(_t_main_file);

            // start client
            {
                int port = Utilities.FindFreePort(0);
                if (port <= 0)
                {
                    SendErrorResponse(response, 3003, "Can not launch oms.exe with a port", null);
                    return;
                }
                ProcessStartInfo info = new ProcessStartInfo();
                info.FileName = Utilities.FindExeDirectory() + "\\oms.exe";
                //info.Arguments = string.Format("-d {0}", Path.GetFileName(_t_main_file), port);
                info.Arguments        = string.Format("-d {0} -p {1}", Path.GetFileName(_t_main_file), port);
                info.WorkingDirectory = _t_work_dir;
                _process = Process.Start(info);

                // Connect
                try
                {
                    System.Threading.Thread.Sleep(20);
                    _tcp_connect = new TcpClient();
                    _tcp_connect.Connect(IPAddress.Parse("127.0.0.1"), port);
                    _net_stream = new NetStream(_tcp_connect.GetStream());
                }
                catch
                {
                    SendErrorResponse(response, 3004, "Can not connect to oms.exe");
                    ClearNetConnect();
                    return;
                }
            }

            SendResponse(response);

            SendEvent(new StoppedEvent(_t_thread, "entry"));

            // immediate handle one break
            WaitForResponse();
        }
示例#25
0
        public override void Handle(NetStream stream, Command command)
        {
            var results = serverObj.WriteValue(command);

            foreach (var r in results)
            {
                stream.Write(r);
            }
        }
示例#26
0
 public void CollectState(NetStream stream)
 {
     if (showDebug)
     {
         Debug.Log(base.name + " Coolect State ");
     }
     NetSignal.encoder.CollectState(stream, motor.value);
     NetSignal.encoder.CollectState(stream, velocity.value);
 }
 public override void Handle(NetStream stream, Command command)
 {
     this.serverObj.EnumPoints(command, (path) => {
         byte[] bs = System.Text.Encoding.UTF8.GetBytes(path);
         stream.Write(bs.Length);
         stream.Write(bs);
     });
     stream.Write(-1);//表示结束
 }
示例#28
0
        public static bool CalculateDelta(NetStream state0, NetStream state1, NetStream delta, bool writeChanged = true)
        {
            bool flag  = state0?.ReadBool() ?? false;
            bool flag2 = state1.ReadBool();
            bool flag3 = flag != flag2;

            delta.Write(flag3);
            return(flag3);
        }
        void init()
        {
            _stream = new NetStream(_server, _port);
            var content = _header.ToJsonString();
            var bs      = Encoding.UTF8.GetBytes(content);

            _stream.Write(bs.Length);
            _stream.Write(bs);
        }
示例#30
0
 public void CollectState(NetStream stream)
 {
     if (showDebug)
     {
         Debug.Log(base.name + " Collected State ");
     }
     NetBoolEncoder.CollectState(stream, leftJoint != null);
     NetBoolEncoder.CollectState(stream, rightJoint != null);
 }
 internal void DeserializeStream(NetStream stream) {
     while (NetSerializer.CanReadMessage(stream)) {
         var message = NetSerializer.ReadNetMessage(stream);
         if (message == null) {
             NetLog.Warning("Failed to parse unreliable message from: " + Connection.Endpoint);
             break;
         }
         Connection.Socket.ReceiveMessage(message, Connection);
     }
     stream.Release();
 }
 /// <summary>
 /// if the invite is accepted, this event will be fired
 /// </summary>
 /// if the stream is null, the connection is dropped
 /// <param name="session">remote session</param>
 /// <param name="stream">Stream handle used for communication</param>
 private void SC_CommunicationStarted(STCSession session, NetStream stream)
 {
     if (stream == null)
     {
         stopChat();
         //MessageBox.Show("Connection Dropped");
     }
     else
     {
         this.Stream = stream;
         this.RemoteSession = session;
         startChat();
     }
 }
示例#33
0
 /// <summary>
 /// Specifies a video stream to be displayed within the boundaries of the Video object in the application.
 /// </summary>
 public void attachNetStream(NetStream netStream)
 {
 }