private bool SendConnect() { Dictionary <string, object> paramaters = new Dictionary <string, object>(); paramaters.Add("app", ""); paramaters.Add("flashVer", "WIN 10,6,602,161"); paramaters.Add("swfUrl", "app:/LolClient.swf/[[DYNAMIC]]/32"); paramaters.Add("tcUrl", "rtmps://" + server + ":" + 2099); paramaters.Add("fpad", false); paramaters.Add("capabilities", 239); paramaters.Add("audioCodecs", 3575); paramaters.Add("videoCodecs", 252); paramaters.Add("videoFunction", 1); paramaters.Add("pageUrl", null); paramaters.Add("objectEncoding", 3); RTMPSEncoder encoder = new RTMPSEncoder(); byte[] connect = encoder.EncodeConnect(paramaters); sslStream.Write(connect, 0, connect.Length); while (!results.ContainsKey(1)) { Thread.Sleep(10); } TypedObject result = results[1]; results.Remove(1); if (result["result"].Equals("_error")) { Error(GetErrorMessage(result), ErrorType.Connect); Disconnect(); return(false); } DSId = result.GetTO("data").GetString("id"); isConnected = true; if (OnConnect != null) { OnConnect(this, EventArgs.Empty); } return(true); }
protected TypedObject WrapBody(object body, string destination, object operation) { TypedObject headers = new TypedObject(); headers.Add("DSRequestTimeout", 60); headers.Add("DSId", DSId); headers.Add("DSEndpoint", "my-rtmps"); TypedObject ret = new TypedObject("flex.messaging.messages.RemotingMessage"); ret.Add("operation", operation); ret.Add("source", null); ret.Add("timestamp", 0); ret.Add("messageId", RTMPSEncoder.RandomUID()); ret.Add("timeToLive", 0); ret.Add("clientId", null); ret.Add("destination", destination); ret.Add("body", body); ret.Add("headers", headers); return ret; }
private int Invoke(TypedObject packet) { int id = NextInvokeID(); pendingInvokes.Add(id); try { RTMPSEncoder encoder = new RTMPSEncoder(); byte[] data = encoder.EncodeInvoke(id, packet); sslStream.Write(data, 0, data.Length); return id; } catch (IOException e) { // Clear the pending invoke pendingInvokes.Remove(id); // Rethrow throw e; } }
private bool SendConnect() { Dictionary<string, object> paramaters = new Dictionary<string, object>(); paramaters.Add("app", ""); paramaters.Add("flashVer", "WIN 10,6,602,161"); paramaters.Add("swfUrl", "app:/LolClient.swf/[[DYNAMIC]]/32"); paramaters.Add("tcUrl", "rtmps://" + server + ":" + 2099); paramaters.Add("fpad", false); paramaters.Add("capabilities", 239); paramaters.Add("audioCodecs", 3575); paramaters.Add("videoCodecs", 252); paramaters.Add("videoFunction", 1); paramaters.Add("pageUrl", null); paramaters.Add("objectEncoding", 3); RTMPSEncoder encoder = new RTMPSEncoder(); byte[] connect = encoder.EncodeConnect(paramaters); sslStream.Write(connect, 0, connect.Length); while (!results.ContainsKey(1)) Thread.Sleep(10); TypedObject result = results[1]; results.Remove(1); if (result["result"].Equals("_error")) { Error(GetErrorMessage(result), ErrorType.Connect); Disconnect(); return false; } DSId = result.GetTO("data").GetString("id"); isConnected = true; if (OnConnect != null) OnConnect(this, EventArgs.Empty); return true; }