Exemple #1
0
		/// <summary>
		/// This method supports the infrastructure and is not intended to be used directly from your code.
		/// </summary>
		public override void Timeout() {
			if (!IsClosed) {
				if (this.IsFlexClient) {
					FlexInvoke flexInvoke = new FlexInvoke();
					StatusASO statusASO = new StatusASO(StatusASO.NC_CONNECT_CLOSED, StatusASO.STATUS, "Connection Timed Out", null, this.ObjectEncoding);
					Call call = new Call("onstatus", new object[] { statusASO });
					flexInvoke.ServiceCall = call;
					//flexInvoke.Cmd = "onstatus";
					//flexInvoke.Parameters = new object[] { statusASO };
					RtmpChannel channel = this.GetChannel(3);
					channel.Write(flexInvoke);
				} else {
					StatusASO statusASO = new StatusASO(StatusASO.NC_CONNECT_CLOSED, StatusASO.ERROR, "Connection Timed Out", null, this.ObjectEncoding);
					RtmpChannel channel = this.GetChannel(3);
					channel.SendStatus(statusASO);
				}
			}
		}
Exemple #2
0
		/// <summary>
		/// Notifies method with parameters.
		/// </summary>
		/// <param name="method">Method name.</param>
		/// <param name="parameters">Parameters passed to the method.</param>
		public void Notify(string method, object[] parameters) {
			IServiceCall serviceCall = new Call(method, parameters);
			Notify(serviceCall);
		}
Exemple #3
0
		/// <summary>
		/// Sends status notification.
		/// </summary>
		/// <param name="status">Status object.</param>
		public void SendStatus(StatusASO status) {
			bool andReturn = !status.code.Equals(StatusASO.NS_DATA_START);
			Invoke invoke;
			if (andReturn) {
				PendingCall call = new PendingCall(null, "onStatus", new object[] { status });
				invoke = new Invoke();
				invoke.InvokeId = 1;
				invoke.ServiceCall = call;
			} else {
				Call call = new Call(null, "onStatus", new object[] { status });
				invoke = (Invoke)new Notify();
				invoke.InvokeId = 1;
				invoke.ServiceCall = call;
			}
			// We send directly to the corresponding stream as for
			// some status codes, no stream has been created and thus
			// "getStreamByChannelId" will fail.
			Write(invoke, _connection.GetStreamIdForChannel(_channelId));
		}
Exemple #4
0
		internal static void Push(RtmpConnection connection, IMessage message, IMessageClient messageClient) {
			if (connection != null) {
				object response = message;
				if (message is BinaryMessage) {
					BinaryMessage binaryMessage = message as BinaryMessage;
					binaryMessage.Update(messageClient);
					byte[] binaryContent = binaryMessage.body as byte[];
					//byte[] destClientBinaryId = messageClient.GetBinaryId();
					//Array.Copy(destClientBinaryId, 0, binaryContent, binaryMessage.PatternPosition, destClientBinaryId.Length);

					RawBinary result = new RawBinary(binaryContent);
					response = result;
				} else {
					//This should be a clone of the original message
					message.SetHeader(MessageBase.DestinationClientIdHeader, messageClient.ClientId);
					message.clientId = messageClient.ClientId;
				}

				RtmpChannel channel = connection.GetChannel(3);
				FlexInvoke reply = new FlexInvoke();
				Call call = new Call("receive", new object[] { response });
				reply.ServiceCall = call;
				//reply.Cmd = "receive";
				//reply.Response = response;
				reply.InvokeId = connection.InvokeId;
				channel.Write(reply);
			}
		}
		static Notify DecodeNotifyOrInvoke(Notify notify, ByteBuffer stream, RtmpHeader header) {
			long start = stream.Position;
			RtmpReader reader = new RtmpReader(stream);
			string action = reader.ReadData() as string;

			if (!(notify is Invoke)) {
				//Don't decode "NetStream.send" requests
				stream.Position = start;
				notify.Data = ByteBuffer.Allocate(stream.Remaining);
				notify.Data.Put(stream);
				//notify.setData(in.asReadOnlyBuffer());
				return notify;
			}

			if (header == null || header.StreamId == 0) {
				double invokeId = (double)reader.ReadData();
				notify.InvokeId = (int)invokeId;
			}

			object[] parameters = Call.EmptyArguments;
			if (stream.HasRemaining) {
#if !(NET_1_1)
				List<object> paramList = new List<object>();
#else
                ArrayList paramList = new ArrayList();
#endif
				object obj = reader.ReadData();

				if (obj is IDictionary) {
					// for connect we get a map
					notify.ConnectionParameters = obj as IDictionary;
				} else if (obj != null) {
					paramList.Add(obj);
				}

				while (stream.HasRemaining) {
					paramList.Add(reader.ReadData());
				}
				parameters = paramList.ToArray();
			}

			int dotIndex = action.LastIndexOf(".");
			string serviceName = (dotIndex == -1) ? null : action.Substring(0, dotIndex);
			string serviceMethod = (dotIndex == -1) ? action : action.Substring(dotIndex + 1, action.Length - dotIndex - 1);

			if (notify is Invoke) {
				PendingCall call = new PendingCall(serviceName, serviceMethod, parameters);
				notify.ServiceCall = call;
			} else {
				Call call = new Call(serviceName, serviceMethod, parameters);
				notify.ServiceCall = call;
			}
			return notify;
		}
		static Notify DecodeStreamMetadata(ByteBuffer stream) {
			RtmpReader reader = new RtmpReader(stream);
			string action = reader.ReadData() as string;
			object obj = reader.ReadData();
			Notify notify = new Notify();
			int dotIndex = action.LastIndexOf(".");
			string serviceName = (dotIndex == -1) ? null : action.Substring(0, dotIndex);
			string serviceMethod = (dotIndex == -1) ? action : action.Substring(dotIndex + 1, action.Length - dotIndex - 1);
			object[] parameters = new object[1] { obj };
			Call call = new Call(serviceName, serviceMethod, parameters);
			notify.ServiceCall = call;
			return notify;
		}