private FileInfo GetStreamFile(IScope scope, string name) { IStreamableFileFactory scopeService = ScopeUtils.GetScopeService(scope, typeof(IStreamableFileFactory)) as IStreamableFileFactory; if ((name.IndexOf(':') == -1) && (name.IndexOf('.') == -1)) { name = "flv:" + name; } log.Info(string.Concat(new object[] { "GetStreamFile factory: ", scopeService, " name: ", name })); foreach (IStreamableFileService service in scopeService.GetServices()) { if (name.StartsWith(service.Prefix + ':')) { name = service.PrepareFilename(name); break; } } IStreamFilenameGenerator generator = ScopeUtils.GetScopeService(scope, typeof(IStreamFilenameGenerator)) as IStreamFilenameGenerator; string fileName = generator.GenerateFilename(scope, name, GenerationType.PLAYBACK); if (generator.ResolvesToAbsolutePath) { return(new FileInfo(fileName)); } return(scope.Context.GetResource(fileName).File); }
public void OnPipeConnectionEvent(PipeConnectionEvent evt) { switch (evt.Type) { case 0: case 1: case 3: case 4: this._compCounter++; break; case 2: case 5: this._compCounter--; if (this._compCounter <= 0) { if (base.HasParent) { (ScopeUtils.GetScopeService(this.Parent, typeof(IProviderService)) as IProviderService).UnregisterBroadcastStream(this.Parent, this.Name); } this._hasRemoved = true; } break; default: throw new NotSupportedException("Event type not supported: " + evt.Type); } }
private void Init() { IStreamableFileFactory scopeService = ScopeUtils.GetScopeService(this._scope, typeof(IStreamableFileFactory)) as IStreamableFileFactory; string directoryName = Path.GetDirectoryName(this._file.FullName); if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } if (!this._file.Exists) { using (this._file.Create()) { } } IStreamableFile streamableFile = scopeService.GetService(this._file).GetStreamableFile(this._file); if ((this._mode == null) || this._mode.Equals("record")) { this._writer = streamableFile.GetWriter(); } else { if (!this._mode.Equals("append")) { throw new NotSupportedException("Illegal mode type: " + this._mode); } this._writer = streamableFile.GetAppendWriter(); } }
public void OnPipeConnectionEvent(PipeConnectionEvent evt) { switch (evt.Type) { case PipeConnectionEvent.CONSUMER_CONNECT_PULL: case PipeConnectionEvent.CONSUMER_CONNECT_PUSH: case PipeConnectionEvent.PROVIDER_CONNECT_PULL: case PipeConnectionEvent.PROVIDER_CONNECT_PUSH: _compCounter++; break; case PipeConnectionEvent.CONSUMER_DISCONNECT: case PipeConnectionEvent.PROVIDER_DISCONNECT: _compCounter--; if (_compCounter <= 0) { // XXX should we synchronize parent before removing? if (HasParent) { IProviderService providerService = ScopeUtils.GetScopeService(this.Parent, typeof(IProviderService)) as IProviderService; providerService.UnregisterBroadcastStream(Parent, Name); } _hasRemoved = true; } break; default: throw new NotSupportedException("Event type not supported: " + evt.Type); } }
private FileInfo GetStreamFile(IScope scope, String name) { IStreamableFileFactory factory = ScopeUtils.GetScopeService(scope, typeof(IStreamableFileFactory)) as IStreamableFileFactory; if (name.IndexOf(':') == -1 && name.IndexOf('.') == -1) { // Default to .flv files if no prefix and no extension is given. name = "flv:" + name; } log.Info("GetStreamFile factory: " + factory + " name: " + name); foreach (IStreamableFileService service in factory.GetServices()) { if (name.StartsWith(service.Prefix + ':')) { name = service.PrepareFilename(name); break; } } IStreamFilenameGenerator filenameGenerator = ScopeUtils.GetScopeService(scope, typeof(IStreamFilenameGenerator)) as IStreamFilenameGenerator; string filename = filenameGenerator.GenerateFilename(scope, name, GenerationType.PLAYBACK); FileInfo file; if (filenameGenerator.ResolvesToAbsolutePath) { file = new FileInfo(filename); } else { file = scope.Context.GetResource(filename).File; } return(file); }
protected override void OnSharedObject(RtmpConnection connection, RtmpChannel channel, RtmpHeader header, SharedObjectMessage message) { ISharedObject sharedObject = null; string name = message.Name; IScope scope = connection.Scope; bool isPersistent = message.IsPersistent; if (scope == null) { SharedObjectMessage message2; if (connection.ObjectEncoding == ObjectEncoding.AMF0) { message2 = new SharedObjectMessage(name, 0, isPersistent); } else { message2 = new FlexSharedObjectMessage(name, 0, isPersistent); } message2.AddEvent(new SharedObjectEvent(SharedObjectEventType.CLIENT_STATUS, "SharedObject.NoObjectFound", "error")); connection.GetChannel(3).Write(message2); } else { ISharedObjectService scopeService = ScopeUtils.GetScopeService(scope, typeof(ISharedObjectService)) as ISharedObjectService; if (!scopeService.HasSharedObject(scope, name)) { ISharedObjectSecurityService service2 = ScopeUtils.GetScopeService(scope, typeof(ISharedObjectSecurityService)) as ISharedObjectSecurityService; if (service2 != null) { IEnumerator sharedObjectSecurity = service2.GetSharedObjectSecurity(); while (sharedObjectSecurity.MoveNext()) { ISharedObjectSecurity current = sharedObjectSecurity.Current as ISharedObjectSecurity; if (!current.IsCreationAllowed(scope, name, isPersistent)) { SendSOCreationFailed(connection, name, isPersistent); return; } } } if (!scopeService.CreateSharedObject(scope, name, isPersistent)) { SendSOCreationFailed(connection, name, isPersistent); return; } } sharedObject = scopeService.GetSharedObject(scope, name); if (sharedObject.IsPersistentObject != isPersistent) { log.Debug(string.Format("Shared object '{0}' persistence mismatch", name)); SendSOPersistenceMismatch(connection, name, isPersistent); } else { sharedObject.DispatchEvent(message); } } }
/// <summary> /// Returns security handlers for this shared object or null if none are found. /// </summary> /// <returns>Collection of ISharedObjectSecurity objects.</returns> private IEnumerator GetSecurityHandlers() { ISharedObjectSecurityService security = ScopeUtils.GetScopeService(this.Parent, typeof(ISharedObjectSecurityService)) as ISharedObjectSecurityService; if (security == null) { return(null); } return(security.GetSharedObjectSecurity()); }
protected override void OnSharedObject(RtmpConnection connection, RtmpChannel channel, RtmpHeader header, SharedObjectMessage message) { ISharedObject so = null; string name = message.Name; IScope scope = connection.Scope; bool persistent = message.IsPersistent; if (scope == null) { // The scope already has been deleted. SendSOCreationFailed(connection, name, persistent); return; } ISharedObjectService sharedObjectService = ScopeUtils.GetScopeService(scope, typeof(ISharedObjectService)) as ISharedObjectService; if (!sharedObjectService.HasSharedObject(scope, name)) { ISharedObjectSecurityService securityService = ScopeUtils.GetScopeService(scope, typeof(ISharedObjectSecurityService)) as ISharedObjectSecurityService; if (securityService != null) { // Check handlers to see if creation is allowed IEnumerator enumerator = securityService.GetSharedObjectSecurity(); while (enumerator.MoveNext()) { ISharedObjectSecurity handler = enumerator.Current as ISharedObjectSecurity; if (!handler.IsCreationAllowed(scope, name, persistent)) { SendSOCreationFailed(connection, name, persistent); return; } } } if (!sharedObjectService.CreateSharedObject(scope, name, persistent)) { SendSOCreationFailed(connection, name, persistent); return; } } so = sharedObjectService.GetSharedObject(scope, name); if (so.IsPersistentObject != persistent) { log.Debug(string.Format("Shared object '{0}' persistence mismatch", name)); SendSOPersistenceMismatch(connection, name, persistent); return; } so.DispatchEvent(message); }
private void Init() { IStreamableFileService service = ((IStreamableFileFactory)ScopeUtils.GetScopeService(this._scope, typeof(IStreamableFileFactory))).GetService(this._file); if (service == null) { log.Error("No service found for " + this._file.FullName); } else { this._reader = service.GetStreamableFile(this._file).GetReader(); if (this._start > 0) { this.Seek(this._start); } } }
public void DeferredClose() { lock (base.SyncRoot) { if (this._keepAliveJobName != null) { (base.Scope.GetService(typeof(ISchedulingService)) as ISchedulingService).RemoveScheduledJob(this._keepAliveJobName); this._keepAliveJobName = null; } if (!base.IsDisposed && !this.IsDisconnected) { this._state = 0; IStreamService scopeService = ScopeUtils.GetScopeService(base.Scope, typeof(IStreamService)) as IStreamService; if (scopeService != null) { lock (((ICollection)this._streams).SyncRoot) { IClientStream[] array = new IClientStream[this._streams.Count]; this._streams.Values.CopyTo(array, 0); foreach (IClientStream stream in array) { if (stream != null) { if (log.get_IsDebugEnabled()) { log.Debug("Closing stream: " + stream.StreamId); } scopeService.deleteStream(this, stream.StreamId); this._streamCount--; } } this._streams.Clear(); } } if (((this._bwContext != null) && (base.Scope != null)) && (base.Scope.Context != null)) { (base.Scope.GetService(typeof(IBWControlService)) as IBWControlService).UnregisterBWControllable(this._bwContext); this._bwContext = null; } base.Close(); this._rtmpServer.OnConnectionClose(this); this._rtmpNetworkStream.Close(); } } }
/// <summary> /// Returns stream length. Method added to get flv player to work. /// </summary> /// <param name="name">Stream name.</param> /// <returns>Returns the length of a stream, in seconds.</returns> public double getStreamLength(string name) { double duration = 0; IProviderService provider = ScopeUtils.GetScopeService(this.Scope, typeof(IProviderService)) as IProviderService; FileInfo file = provider.GetVODProviderFile(this.Scope, name); if (file != null) { IStreamableFileFactory factory = (IStreamableFileFactory)ScopeUtils.GetScopeService(this.Scope, typeof(IStreamableFileFactory)) as IStreamableFileFactory; IStreamableFileService service = factory.GetService(file); if (service != null) { ITagReader reader = null; try { IStreamableFile streamFile = service.GetStreamableFile(file); reader = streamFile.GetReader(); duration = (double)reader.Duration / 1000; } catch (IOException ex) { if (log.IsErrorEnabled) { log.Error(string.Format("Error reading stream file {0}. {1}", file.FullName, ex.Message)); } } finally { if (reader != null) { reader.Close(); } } } else { if (log.IsErrorEnabled) { log.Error(string.Format("No service found for {0}", file.FullName)); } } file = null; } return(duration); }
/// <summary> /// Play a specific IPlayItem. /// The strategy for now is VOD first, Live second. /// </summary> /// <param name="item">Item to play</param> protected void Play(IPlayItem item) { // Return if already playing if (_state != State.STOPPED) { return; } // Assume this is not live stream bool isLive = false; IProviderService providerService = ScopeUtils.GetScopeService(this.Scope, typeof(IProviderService)) as IProviderService; _msgIn = providerService.GetVODProviderInput(this.Scope, item.Name); if (_msgIn == null) { _msgIn = providerService.GetLiveProviderInput(this.Scope, item.Name, true); isLive = true; } if (_msgIn == null) { log.Warn("Can't get both VOD and Live input from providerService"); return; } _state = State.PLAYING; _currentItem = item; SendResetMessage(); _msgIn.Subscribe(this, null); if (isLive) { if (item.Length >= 0) { PlayItemScheduledJob job = new PlayItemScheduledJob(this); _liveJobName = _schedulingService.AddScheduledOnceJob(item.Length, job); } } else { long start = item.Start; if (start < 0) { start = 0; } SendVODInitCM(_msgIn, (int)start); StartBroadcastVOD(); } }
/// <summary> /// Initializes file provider. Creates streamable file factory and service, seeks to start position. /// </summary> private void Init() { IStreamableFileFactory factory = (IStreamableFileFactory)ScopeUtils.GetScopeService(_scope, typeof(IStreamableFileFactory)); IStreamableFileService service = factory.GetService(_file); if (service == null) { log.Error("No service found for " + _file.FullName); return; } IStreamableFile streamFile = service.GetStreamableFile(_file); _reader = streamFile.GetReader(); if (_start > 0) { Seek(_start); } }
private void Init() { IStreamableFileFactory factory = ScopeUtils.GetScopeService(_scope, typeof(IStreamableFileFactory)) as IStreamableFileFactory; string directory = Path.GetDirectoryName(_file.FullName); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } if (!_file.Exists) { // Maybe the (previously existing) file has been deleted using (FileStream fs = _file.Create()){} } /* * else if (_file.IsReadOnly) * { * throw new IOException("The file is read-only"); * } */ IStreamableFileService service = factory.GetService(_file); IStreamableFile flv = service.GetStreamableFile(_file); if (_mode == null || _mode.Equals(Constants.ClientStreamModeRecord)) { _writer = flv.GetWriter(); } else if (_mode.Equals(Constants.ClientStreamModeAppend)) { _writer = flv.GetAppendWriter(); } else { throw new NotSupportedException("Illegal mode type: " + _mode); } }
protected override void OnInvoke(RtmpConnection connection, RtmpChannel channel, RtmpHeader header, Notify invoke) { IServiceCall serviceCall = invoke.ServiceCall; // If it's a callback for server remote call then pass it over to callbacks handler // and return if (serviceCall.ServiceMethodName.Equals("_result") || serviceCall.ServiceMethodName.Equals("_error")) { HandlePendingCallResult(connection, invoke); return; } bool disconnectOnReturn = false; string action = null; if (serviceCall.ServiceName == null) { action = serviceCall.ServiceMethodName; switch (action) { case ACTION_CONNECT: { if (!connection.IsConnected) { IDictionary parameters = invoke.ConnectionParameters; string host = null; if (parameters.Contains("tcUrl")) { host = GetHostname(parameters["tcUrl"] as string); } if (host != null && host.IndexOf(":") != -1) { // Remove default port from connection string host = host.Substring(0, host.IndexOf(":")); } string app = parameters["app"] as string; string path = parameters["app"] as string; // App name as path, but without query string if there is one if (path != null && path.IndexOf("?") != -1) { int idx = path.IndexOf("?"); parameters["queryString"] = path.Substring(idx); path = path.Substring(0, idx); } parameters["path"] = path; connection.Setup(host, path, parameters); try { //IGlobalScope global = this.Endpoint.LookupGlobal(host, path); IGlobalScope global = this.Endpoint.GetMessageBroker().GlobalScope; if (global == null) { serviceCall.Status = Call.STATUS_SERVICE_NOT_FOUND; if (serviceCall is IPendingServiceCall) { StatusASO status = StatusASO.GetStatusObject(StatusASO.NC_CONNECT_INVALID_APPLICATION, connection.ObjectEncoding); status.description = "No global scope on this server."; (serviceCall as IPendingServiceCall).Result = status; } log.Info(string.Format("No application scope found for {0} on host {1}. Misspelled or missing application folder?", path, host)); disconnectOnReturn = true; } else { IScopeContext context = global.Context; IScope scope = null; try { scope = context.ResolveScope(global, path); } catch (ScopeNotFoundException /*exception*/) { if (log.IsErrorEnabled) { log.Error(__Res.GetString(__Res.Scope_NotFound, path)); } serviceCall.Status = Call.STATUS_SERVICE_NOT_FOUND; if (serviceCall is IPendingServiceCall) { StatusASO status = StatusASO.GetStatusObject(StatusASO.NC_CONNECT_REJECTED, connection.ObjectEncoding); status.description = "No scope \"" + path + "\" on this server."; (serviceCall as IPendingServiceCall).Result = status; } disconnectOnReturn = true; } catch (ScopeShuttingDownException) { serviceCall.Status = Call.STATUS_APP_SHUTTING_DOWN; if (serviceCall is IPendingServiceCall) { StatusASO status = StatusASO.GetStatusObject(StatusASO.NC_CONNECT_APPSHUTDOWN, connection.ObjectEncoding); status.description = "Application at \"" + path + "\" is currently shutting down."; (serviceCall as IPendingServiceCall).Result = status; } log.Info(string.Format("Application at {0} currently shutting down on {1}", path, host)); disconnectOnReturn = true; } if (scope != null) { if (log.IsInfoEnabled) { log.Info(__Res.GetString(__Res.Scope_Connect, scope.Name)); } bool okayToConnect; try { //The only way to differentiate NetConnection.connect() and Consumer.subscribe() seems to be the app name if (app == string.Empty) { connection.SetIsFlexClient(true); okayToConnect = connection.Connect(scope, serviceCall.Arguments); if (okayToConnect) { if (serviceCall.Arguments != null && serviceCall.Arguments.Length >= 3) { string credentials = serviceCall.Arguments[2] as string; if (credentials != null && credentials != string.Empty) { MessageBroker messageBroker = this.Endpoint.GetMessageBroker(); AuthenticationService authenticationService = messageBroker.GetService(AuthenticationService.ServiceId) as AuthenticationService; authenticationService.Authenticate(credentials); } } //FDS 2.0.1 fds.swc if (serviceCall.Arguments != null && serviceCall.Arguments.Length == 1) { string credentials = serviceCall.Arguments[0] as string; if (credentials != null && credentials != string.Empty) { MessageBroker messageBroker = this.Endpoint.GetMessageBroker(); AuthenticationService authenticationService = messageBroker.GetService(AuthenticationService.ServiceId) as AuthenticationService; authenticationService.Authenticate(credentials); } } } } else { connection.SetIsFlexClient(false); okayToConnect = connection.Connect(scope, serviceCall.Arguments); } if (okayToConnect) { if (log.IsDebugEnabled) { log.Debug("Connected RtmpClient: " + connection.Client.Id); } serviceCall.Status = Call.STATUS_SUCCESS_RESULT; if (serviceCall is IPendingServiceCall) { StatusASO statusASO = StatusASO.GetStatusObject(StatusASO.NC_CONNECT_SUCCESS, connection.ObjectEncoding); statusASO.Add("id", connection.Client.Id); (serviceCall as IPendingServiceCall).Result = statusASO; } // Measure initial roundtrip time after connecting connection.GetChannel((byte)2).Write(new Ping(Ping.StreamBegin, 0, -1)); connection.StartRoundTripMeasurement(); } else { if (log.IsDebugEnabled) { log.Debug("Connect failed"); } serviceCall.Status = Call.STATUS_ACCESS_DENIED; if (serviceCall is IPendingServiceCall) { (serviceCall as IPendingServiceCall).Result = StatusASO.GetStatusObject(StatusASO.NC_CONNECT_REJECTED, connection.ObjectEncoding); } disconnectOnReturn = true; } } catch (ClientRejectedException rejected) { if (log.IsDebugEnabled) { log.Debug("Connect rejected"); } serviceCall.Status = Call.STATUS_ACCESS_DENIED; if (serviceCall is IPendingServiceCall) { StatusASO statusASO = StatusASO.GetStatusObject(StatusASO.NC_CONNECT_REJECTED, connection.ObjectEncoding); statusASO.Application = rejected.Reason; (serviceCall as IPendingServiceCall).Result = statusASO; } disconnectOnReturn = true; } } } } catch (Exception ex) { if (log.IsErrorEnabled) { log.Error("Error connecting", ex); } serviceCall.Status = Call.STATUS_GENERAL_EXCEPTION; if (serviceCall is IPendingServiceCall) { (serviceCall as IPendingServiceCall).Result = StatusASO.GetStatusObject(StatusASO.NC_CONNECT_FAILED, connection.ObjectEncoding); } disconnectOnReturn = true; } } else { // Service calls, must be connected. InvokeCall(connection, serviceCall); } } break; case ACTION_DISCONNECT: connection.Close(); break; case ACTION_CREATE_STREAM: case ACTION_DELETE_STREAM: case ACTION_RELEASE_STREAM: case ACTION_PUBLISH: case ACTION_PLAY: case ACTION_SEEK: case ACTION_PAUSE: case ACTION_CLOSE_STREAM: case ACTION_RECEIVE_VIDEO: case ACTION_RECEIVE_AUDIO: { IStreamService streamService = ScopeUtils.GetScopeService(connection.Scope, typeof(IStreamService)) as IStreamService; StatusASO status = null; try { if (!InvokeCall(connection, serviceCall, streamService)) { status = StatusASO.GetStatusObject(StatusASO.NS_INVALID_ARGUMENT, connection.ObjectEncoding); status.description = "Failed to " + action + " (stream ID: " + header.StreamId + ")"; } } catch (Exception ex) { log.Error("Error while invoking " + action + " on stream service.", ex); status = StatusASO.GetStatusObject(StatusASO.NS_FAILED, connection.ObjectEncoding); status.description = "Error while invoking " + action + " (stream ID: " + header.StreamId + ")"; status.details = ex.Message; } if (status != null) { channel.SendStatus(status); } } break; default: if (connection.IsConnected) { InvokeCall(connection, serviceCall); } else { // Warn user attemps to call service without being connected if (log.IsWarnEnabled) { log.Warn("Not connected, closing connection"); } connection.Close(); } break; } } /* * if(invoke is FlexInvoke) * { * FlexInvoke reply = new FlexInvoke(); * reply.InvokeId = invoke.InvokeId; * reply.SetResponseSuccess(); * //TODO * if( serviceCall is IPendingServiceCall ) * { * IPendingServiceCall pendingCall = (IPendingServiceCall)serviceCall; * reply.Response = pendingCall.Result; * } * channel.Write(reply); * } * else if(invoke is Invoke) */ if (invoke is Invoke) { if ((header.StreamId != 0) && (serviceCall.Status == Call.STATUS_SUCCESS_VOID || serviceCall.Status == Call.STATUS_SUCCESS_NULL)) { if (log.IsDebugEnabled) { log.Debug("Method does not have return value, do not reply"); } return; } // The client expects a result for the method call. Invoke reply = new Invoke(); reply.ServiceCall = serviceCall; reply.InvokeId = invoke.InvokeId; //sending reply channel.Write(reply); } if (disconnectOnReturn) { connection.Close(); } if (action == ACTION_CONNECT) { connection.Context.ObjectEncoding = connection.ObjectEncoding; } }
public void publish(string name, string mode) { IConnection connection = FluorineContext.Current.Connection; if (connection is IStreamCapableConnection) { IStreamCapableConnection connection2 = connection as IStreamCapableConnection; IScope scope = connection.Scope; int currentStreamId = this.GetCurrentStreamId(); if ((name == null) || string.Empty.Equals(name)) { this.SendNSFailed(connection2 as RtmpConnection, "The stream name may not be empty.", name, currentStreamId); } else { IStreamSecurityService scopeService = ScopeUtils.GetScopeService(scope, typeof(IStreamSecurityService)) as IStreamSecurityService; if (scopeService != null) { IEnumerator streamPublishSecurity = scopeService.GetStreamPublishSecurity(); while (streamPublishSecurity.MoveNext()) { IStreamPublishSecurity current = streamPublishSecurity.Current as IStreamPublishSecurity; if (!current.IsPublishAllowed(scope, name, mode)) { this.SendNSFailed(connection2 as RtmpConnection, "You are not allowed to publish the stream.", name, currentStreamId); return; } } } IBroadcastScope broadcastScope = this.GetBroadcastScope(scope, name); if ((broadcastScope != null) && (broadcastScope.GetProviders().Count > 0)) { StatusASO status = new StatusASO("NetStream.Publish.BadName") { clientid = currentStreamId, details = name, level = "error" }; (connection2 as RtmpConnection).GetChannel((byte)(4 + ((currentStreamId - 1) * 5))).SendStatus(status); } else { IClientStream streamById = connection2.GetStreamById(currentStreamId); if ((streamById == null) || (streamById is IClientBroadcastStream)) { bool flag = false; if (streamById == null) { streamById = connection2.NewBroadcastStream(currentStreamId); flag = true; } IClientBroadcastStream broadcastStream = streamById as IClientBroadcastStream; try { broadcastStream.PublishedName = name; IScopeContext context = connection.Scope.Context; IProviderService service2 = ScopeUtils.GetScopeService(connection.Scope, typeof(IProviderService)) as IProviderService; if (service2.RegisterBroadcastStream(connection.Scope, name, broadcastStream)) { broadcastScope = this.GetBroadcastScope(connection.Scope, name); broadcastScope.SetAttribute("_transient_publishing_stream", broadcastStream); if (connection is BaseConnection) { (connection as BaseConnection).RegisterBasicScope(broadcastScope); } } if ("record".Equals(mode)) { broadcastStream.Start(); broadcastStream.SaveAs(name, false); } else if ("append".Equals(mode)) { broadcastStream.Start(); broadcastStream.SaveAs(name, true); } else if ("live".Equals(mode)) { broadcastStream.Start(); } broadcastStream.StartPublishing(); } catch (IOException exception) { StatusASO saso2 = new StatusASO("NetStream.Record.NoAccess") { clientid = currentStreamId, description = "The file could not be created/written to." + exception.Message, details = name, level = "error" }; (connection2 as RtmpConnection).GetChannel((byte)(4 + ((currentStreamId - 1) * 5))).SendStatus(saso2); broadcastStream.Close(); if (flag) { connection2.DeleteStreamById(currentStreamId); } } catch (Exception exception2) { log.Warn("Publish caught exception", exception2); } } } } } }
/// <summary> /// Saves the broadcast stream as a file. /// </summary> /// <param name="name">The path of the file relative to the scope.</param> /// <param name="isAppend">Whether to append to the end of file.</param> public void SaveAs(string name, bool isAppend) { try { IScope scope = this.Scope; IStreamFilenameGenerator generator = ScopeUtils.GetScopeService(scope, typeof(IStreamFilenameGenerator)) as IStreamFilenameGenerator; string filename = generator.GenerateFilename(scope, name, ".flv", GenerationType.RECORD); // Get file for that filename FileInfo file; if (generator.ResolvesToAbsolutePath) { file = new FileInfo(filename); } else { file = scope.Context.GetResource(filename).File; } if (!isAppend) { if (file.Exists) { // Per livedoc of FCS/FMS: // When "live" or "record" is used, // any previously recorded stream with the same stream URI is deleted. file.Delete(); } } else { if (!file.Exists) { // Per livedoc of FCS/FMS: // If a recorded stream at the same URI does not already exist, // "append" creates the stream as though "record" was passed. isAppend = false; } } if (!file.Exists) { // Make sure the destination directory exists string directory = Path.GetDirectoryName(file.FullName); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } } if (!file.Exists) { using (FileStream fs = file.Create()) { } } FileConsumer fc = new FileConsumer(scope, file); #if !(NET_1_1) Dictionary <string, object> parameterMap = new Dictionary <string, object>(); #else Hashtable parameterMap = new Hashtable(); #endif if (isAppend) { parameterMap.Add("mode", "append"); } else { parameterMap.Add("mode", "record"); } if (null == _recordPipe) { _recordPipe = new InMemoryPushPushPipe(); } _recordPipe.Subscribe(fc, parameterMap); _recordingFilename = filename; } catch (IOException ex) { log.Error("Save as exception", ex); } }
public void play(string name, double start, double length, bool flushPlaylist) { IConnection connection = FluorineContext.Current.Connection; if (connection is IStreamCapableConnection) { IStreamCapableConnection connection2 = connection as IStreamCapableConnection; IScope scope = connection.Scope; int currentStreamId = this.GetCurrentStreamId(); if ((name == null) || string.Empty.Equals(name)) { this.SendNSFailed(connection2 as RtmpConnection, "The stream name may not be empty.", name, currentStreamId); } else { IStreamSecurityService scopeService = ScopeUtils.GetScopeService(scope, typeof(IStreamSecurityService)) as IStreamSecurityService; if (scopeService != null) { IEnumerator streamPlaybackSecurity = scopeService.GetStreamPlaybackSecurity(); while (streamPlaybackSecurity.MoveNext()) { IStreamPlaybackSecurity current = streamPlaybackSecurity.Current as IStreamPlaybackSecurity; if (!current.IsPlaybackAllowed(scope, name, (long)start, (long)length, flushPlaylist)) { this.SendNSFailed(connection2 as RtmpConnection, "You are not allowed to play the stream.", name, currentStreamId); return; } } } IClientStream streamById = connection2.GetStreamById(currentStreamId); bool flag = false; if (streamById == null) { streamById = connection2.NewPlaylistSubscriberStream(currentStreamId); streamById.Start(); flag = true; } if (streamById is ISubscriberStream) { ISubscriberStream stream2 = streamById as ISubscriberStream; SimplePlayItem item = new SimplePlayItem { Name = name, Start = (long)start, Length = (long)length }; if (stream2 is IPlaylistSubscriberStream) { IPlaylistSubscriberStream stream3 = stream2 as IPlaylistSubscriberStream; if (flushPlaylist) { stream3.RemoveAllItems(); } stream3.AddItem(item); } else if (stream2 is ISingleItemSubscriberStream) { ISingleItemSubscriberStream stream4 = stream2 as ISingleItemSubscriberStream; stream4.PlayItem = item; } else { return; } try { stream2.Play(); } catch (IOException exception) { if (flag) { streamById.Close(); connection2.DeleteStreamById(currentStreamId); } this.SendNSFailed(connection2 as RtmpConnection, exception.Message, name, currentStreamId); } } } } }
public ISharedObject GetSharedObject(IScope scope, string name) { ISharedObjectService scopeService = (ISharedObjectService)ScopeUtils.GetScopeService(scope, typeof(ISharedObjectService)); return(scopeService.GetSharedObject(scope, name)); }
/// <summary> /// Returns a collection of available SharedObject names. /// </summary> /// <param name="scope">Scope that SharedObjects belong to.</param> /// <returns>Collection of available SharedObject names.</returns> public ICollection GetSharedObjectNames(IScope scope) { ISharedObjectService service = (ISharedObjectService)ScopeUtils.GetScopeService(scope, typeof(ISharedObjectService)); return(service.GetSharedObjectNames(scope)); }
/// <summary> /// <para> /// Deletes persistent shared objects specified by name and clears all /// properties from active shared objects (persistent and nonpersistent). The /// name parameter specifies the name of a shared object, which can include a /// slash (/) as a delimiter between directories in the path. The last /// element in the path can contain wildcard patterns (for example, a /// question mark [?] and an asterisk [*]) or a shared object name. The /// ClearSharedObjects() method traverses the shared object hierarchy along /// the specified path and clears all the shared objects. Specifying a slash /// (/) clears all the shared objects associated with an application /// instance. /// </para> /// The following values are possible for the soPath parameter: /// <list type="table"> /// <listheader> /// <term>soPath parameter</term> /// <description>action</description> /// </listheader> /// <item><term></term> /// <description>clears all local and persistent shared objects associated with the instance</description></item> /// <item><term>/foo/bar</term> /// <description>clears the shared object /foo/bar; if bar is a directory name, no shared objects are deleted</description></item> /// <item><term>/foo/bar/*</term> /// <description>clears all shared objects stored under the instance directory</description></item> /// <item><term>/foo/bar.</term> /// <description>the bar directory is also deleted if no persistent shared objects are in use within this namespace</description></item> /// <item><term>/foo/bar/XX??</term> /// <description>clears all shared objects that begin with XX, followed by any two characters</description></item> /// </list> /// If a directory name matches this specification, all the shared objects within this directory are cleared. /// /// If you call the ClearSharedObjects() method and the specified path /// matches a shared object that is currently active, all its properties are /// deleted, and a "clear" event is sent to all subscribers of the shared /// object. If it is a persistent shared object, the persistent store is also cleared. /// </summary> /// <param name="scope">Scope that shared object belongs to.</param> /// <param name="name">Name of SharedObject.</param> /// <returns>true if successful, false otherwise.</returns> public bool ClearSharedObjects(IScope scope, string name) { ISharedObjectService service = (ISharedObjectService)ScopeUtils.GetScopeService(scope, typeof(ISharedObjectService)); return(service.ClearSharedObjects(scope, name)); }
public void play(string name, double start, double length, bool flushPlaylist) { IConnection connection = FluorineContext.Current.Connection; if (!(connection is IStreamCapableConnection)) { return; } IStreamCapableConnection streamConnection = connection as IStreamCapableConnection; IScope scope = connection.Scope; int streamId = GetCurrentStreamId(); if (name == null || string.Empty.Equals(name)) { SendNSFailed(streamConnection as RtmpConnection, "The stream name may not be empty.", name, streamId); return; } IStreamSecurityService security = ScopeUtils.GetScopeService(scope, typeof(IStreamSecurityService)) as IStreamSecurityService; if (security != null) { IEnumerator handlers = security.GetStreamPlaybackSecurity(); while (handlers.MoveNext()) { IStreamPlaybackSecurity handler = handlers.Current as IStreamPlaybackSecurity; if (!handler.IsPlaybackAllowed(scope, name, (long)start, (long)length, flushPlaylist)) { SendNSFailed(streamConnection as RtmpConnection, "You are not allowed to play the stream.", name, streamId); return; } } } IClientStream stream = streamConnection.GetStreamById(streamId); bool created = false; if (stream == null) { stream = streamConnection.NewPlaylistSubscriberStream(streamId); stream.Start(); created = true; } if (!(stream is ISubscriberStream)) { return; } ISubscriberStream subscriberStream = stream as ISubscriberStream; SimplePlayItem item = new SimplePlayItem(); item.Name = name; item.Start = (long)start; item.Length = (long)length; if (subscriberStream is IPlaylistSubscriberStream) { IPlaylistSubscriberStream playlistStream = subscriberStream as IPlaylistSubscriberStream; if (flushPlaylist) { playlistStream.RemoveAllItems(); } playlistStream.AddItem(item); } else if (subscriberStream is ISingleItemSubscriberStream) { ISingleItemSubscriberStream singleStream = subscriberStream as ISingleItemSubscriberStream; singleStream.PlayItem = item; } else { // not supported by this stream service return; } try { subscriberStream.Play(); } catch (System.IO.IOException ex) { if (created) { stream.Close(); streamConnection.DeleteStreamById(streamId); } SendNSFailed(streamConnection as RtmpConnection, ex.Message, name, streamId); } }
public void SaveAs(string name, bool isAppend) { FileInfo file; if (log.get_IsDebugEnabled()) { log.Debug(string.Concat(new object[] { "SaveAs - name: ", name, " append: ", isAppend })); } IStreamCapableConnection connection = base.Connection; if (connection == null) { throw new IOException("Stream is no longer connected"); } IScope scope = connection.Scope; IStreamFilenameGenerator scopeService = ScopeUtils.GetScopeService(scope, typeof(IStreamFilenameGenerator)) as IStreamFilenameGenerator; string fileName = scopeService.GenerateFilename(scope, name, ".flv", GenerationType.RECORD); if (scopeService.ResolvesToAbsolutePath) { file = new FileInfo(fileName); } else { file = scope.Context.GetResource(fileName).File; } if (!isAppend) { if (file.Exists) { file.Delete(); } } else if (!file.Exists) { isAppend = false; } file = new FileInfo(file.FullName); if (!file.Exists) { string directoryName = Path.GetDirectoryName(file.FullName); if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } } if (!file.Exists) { using (file.Create()) { } } if (log.get_IsDebugEnabled()) { log.Debug("Recording file: " + file.FullName); } this._recordingFile = new FileConsumer(scope, file); Dictionary <string, object> parameterMap = new Dictionary <string, object>(); if (isAppend) { parameterMap.Add("mode", "append"); } else { parameterMap.Add("mode", "record"); } this._recordPipe.Subscribe(this._recordingFile, parameterMap); this._recording = true; this._recordingFilename = fileName; }
/// <summary> /// Returns shared object from given scope by name. /// </summary> /// <param name="scope">Scope that shared object belongs to.</param> /// <param name="name">Name of SharedObject.</param> /// <param name="persistent">Whether SharedObject instance should be persistent or not.</param> /// <returns>Shared object instance with the specifed name.</returns> public ISharedObject GetSharedObject(IScope scope, string name, bool persistent) { ISharedObjectService service = (ISharedObjectService)ScopeUtils.GetScopeService(scope, typeof(ISharedObjectService)); return(service.GetSharedObject(scope, name, persistent)); }
public void publish(string name, string mode) { IConnection connection = FluorineContext.Current.Connection; if (!(connection is IStreamCapableConnection)) { return; } IStreamCapableConnection streamConnection = connection as IStreamCapableConnection; IScope scope = connection.Scope; int streamId = GetCurrentStreamId(); if (name == null || string.Empty.Equals(name)) { SendNSFailed(streamConnection as RtmpConnection, "The stream name may not be empty.", name, streamId); return; } IStreamSecurityService security = ScopeUtils.GetScopeService(scope, typeof(IStreamSecurityService)) as IStreamSecurityService; if (security != null) { IEnumerator handlers = security.GetStreamPublishSecurity(); while (handlers.MoveNext()) { IStreamPublishSecurity handler = handlers.Current as IStreamPublishSecurity; if (!handler.IsPublishAllowed(scope, name, mode)) { SendNSFailed(streamConnection as RtmpConnection, "You are not allowed to publish the stream.", name, streamId); return; } } } IBroadcastScope bsScope = GetBroadcastScope(scope, name); if (bsScope != null && bsScope.GetProviders().Count > 0) { // Another stream with that name is already published. StatusASO badName = new StatusASO(StatusASO.NS_PUBLISH_BADNAME); badName.clientid = streamId; badName.details = name; badName.level = "error"; // FIXME: there should be a direct way to send the status RtmpChannel channel = (streamConnection as RtmpConnection).GetChannel((byte)(4 + ((streamId - 1) * 5))); channel.SendStatus(badName); return; } IClientStream stream = streamConnection.GetStreamById(streamId); if (stream != null && !(stream is IClientBroadcastStream)) { return; } bool created = false; if (stream == null) { stream = streamConnection.NewBroadcastStream(streamId); created = true; } IClientBroadcastStream bs = stream as IClientBroadcastStream; try { bs.PublishedName = name; IScopeContext context = connection.Scope.Context; //IProviderService providerService = (IProviderService)context.getBean(IProviderService.BEAN_NAME); IProviderService providerService = ScopeUtils.GetScopeService(connection.Scope, typeof(IProviderService)) as IProviderService; // TODO handle registration failure if (providerService.RegisterBroadcastStream(connection.Scope, name, bs)) { bsScope = GetBroadcastScope(connection.Scope, name); bsScope.SetAttribute(Constants.BroadcastScopeStreamAttribute, bs); if (connection is BaseConnection) { (connection as BaseConnection).RegisterBasicScope(bsScope); } } if (Constants.ClientStreamModeRecord.Equals(mode)) { bs.Start(); bs.SaveAs(name, false); } else if (Constants.ClientStreamModeAppend.Equals(mode)) { bs.Start(); bs.SaveAs(name, true); } else if (Constants.ClientStreamModeLive.Equals(mode)) { bs.Start(); } bs.StartPublishing(); } catch (System.IO.IOException ex) { StatusASO accessDenied = new StatusASO(StatusASO.NS_RECORD_NOACCESS); accessDenied.clientid = streamId; accessDenied.description = "The file could not be created/written to." + ex.Message; accessDenied.details = name; accessDenied.level = "error"; // FIXME: there should be a direct way to send the status RtmpChannel channel = (streamConnection as RtmpConnection).GetChannel((byte)(4 + ((streamId - 1) * 5))); channel.SendStatus(accessDenied); bs.Close(); if (created) { streamConnection.DeleteStreamById(streamId); } } catch (Exception ex) { log.Warn("Publish caught exception", ex); } }
/// <summary> /// Returns list of stream names broadcasted in scope. Broadcast stream name is somewhat different /// from server stream name. Server stream name is just an ID assigned to every created stream. Broadcast stream name /// is the name that is being used to subscribe to the stream at client side, that is, in <c>NetStream.play</c> call. /// </summary> /// <param name="scope">Scope to retrieve broadcasted stream names.</param> /// <returns>List of broadcasted stream names.</returns> public IEnumerator GetBroadcastStreamNames(IScope scope) { IProviderService service = ScopeUtils.GetScopeService(scope, typeof(IProviderService)) as IProviderService; return(service.GetBroadcastStreamNames(scope)); }
/// <summary> /// Checks whether there is a SharedObject with given scope and name. /// </summary> /// <param name="scope">Scope that shared object belongs to.</param> /// <param name="name">Name of SharedObject.</param> /// <returns>true if SharedObject exists, false otherwise.</returns> public bool HasSharedObject(IScope scope, string name) { ISharedObjectService service = (ISharedObjectService)ScopeUtils.GetScopeService(scope, typeof(ISharedObjectService)); return service.HasSharedObject(scope, name); }
/// <summary> /// Saves broadcasted stream. /// </summary> /// <param name="name"></param> /// <param name="isAppend"></param> public void SaveAs(string name, bool isAppend) { if (log.IsDebugEnabled) { log.Debug("SaveAs - name: " + name + " append: " + isAppend); } // Get stream scope IStreamCapableConnection connection = this.Connection; if (connection == null) { // TODO: throw other exception here? throw new IOException("Stream is no longer connected"); } IScope scope = connection.Scope; // Get stream filename generator IStreamFilenameGenerator generator = ScopeUtils.GetScopeService(scope, typeof(IStreamFilenameGenerator)) as IStreamFilenameGenerator; // Generate filename string filename = generator.GenerateFilename(scope, name, ".flv", GenerationType.RECORD); // Get file for that filename FileInfo file; if (generator.ResolvesToAbsolutePath) { file = new FileInfo(filename); } else { file = scope.Context.GetResource(filename).File; } // If append mode is on... if (!isAppend) { if (file.Exists) { // Per livedoc of FCS/FMS: // When "live" or "record" is used, // any previously recorded stream with the same stream URI is deleted. file.Delete(); } } else { if (!file.Exists) { // Per livedoc of FCS/FMS: // If a recorded stream at the same URI does not already exist, // "append" creates the stream as though "record" was passed. isAppend = false; } } //Requery file = new FileInfo(file.FullName); if (!file.Exists) { // Make sure the destination directory exists string directory = Path.GetDirectoryName(file.FullName); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } } if (!file.Exists) { using (FileStream fs = file.Create()) { } } if (log.IsDebugEnabled) { log.Debug("Recording file: " + file.FullName); } _recordingFile = new FileConsumer(scope, file); #if !(NET_1_1) Dictionary <string, object> parameterMap = new Dictionary <string, object>(); #else Hashtable parameterMap = new Hashtable(); #endif if (isAppend) { parameterMap.Add("mode", "append"); } else { parameterMap.Add("mode", "record"); } _recordPipe.Subscribe(_recordingFile, parameterMap); _recording = true; _recordingFilename = filename; }
protected override void OnInvoke(RtmpConnection connection, RtmpChannel channel, RtmpHeader header, Notify invoke) { IServiceCall serviceCall = invoke.ServiceCall; if (serviceCall.ServiceMethodName.Equals("_result") || serviceCall.ServiceMethodName.Equals("_error")) { base.HandlePendingCallResult(connection, invoke); } else { bool flag = false; string serviceMethodName = null; if (serviceCall.ServiceName == null) { StatusASO statusObject; Exception exception2; serviceMethodName = serviceCall.ServiceMethodName; switch (serviceMethodName) { case "connect": { if (connection.IsConnected) { InvokeCall(connection, serviceCall); break; } IDictionary connectionParameters = invoke.ConnectionParameters; string host = null; if (connectionParameters.Contains("tcUrl")) { host = BaseRtmpHandler.GetHostname(connectionParameters["tcUrl"] as string); } if ((host != null) && (host.IndexOf(":") != -1)) { host = host.Substring(0, host.IndexOf(":")); } string str3 = connectionParameters["app"] as string; string path = connectionParameters["app"] as string; if ((path != null) && (path.IndexOf("?") != -1)) { int index = path.IndexOf("?"); connectionParameters["queryString"] = path.Substring(index); path = path.Substring(0, index); } connectionParameters["path"] = path; connection.Setup(host, path, connectionParameters); try { IGlobalScope globalScope = this.Endpoint.GetMessageBroker().GlobalScope; if (globalScope == null) { serviceCall.Status = 0x10; if (serviceCall is IPendingServiceCall) { statusObject = StatusASO.GetStatusObject("NetConnection.Connect.InvalidApp", connection.ObjectEncoding); statusObject.description = "No global scope on this server."; (serviceCall as IPendingServiceCall).Result = statusObject; } log.Info(string.Format("No application scope found for {0} on host {1}. Misspelled or missing application folder?", path, host)); flag = true; } else { IScopeContext context = globalScope.Context; IScope scope = null; try { scope = context.ResolveScope(globalScope, path); } catch (ScopeNotFoundException) { if (log.get_IsErrorEnabled()) { log.Error(__Res.GetString("Scope_NotFound", new object[] { path })); } serviceCall.Status = 0x10; if (serviceCall is IPendingServiceCall) { statusObject = StatusASO.GetStatusObject("NetConnection.Connect.Rejected", connection.ObjectEncoding); statusObject.description = "No scope \"" + path + "\" on this server."; (serviceCall as IPendingServiceCall).Result = statusObject; } flag = true; } catch (ScopeShuttingDownException) { serviceCall.Status = 0x15; if (serviceCall is IPendingServiceCall) { statusObject = StatusASO.GetStatusObject("NetConnection.Connect.AppShutdown", connection.ObjectEncoding); statusObject.description = "Application at \"" + path + "\" is currently shutting down."; (serviceCall as IPendingServiceCall).Result = statusObject; } log.Info(string.Format("Application at {0} currently shutting down on {1}", path, host)); flag = true; } if (scope != null) { StatusASO saso2; if (log.get_IsInfoEnabled()) { log.Info(__Res.GetString("Scope_Connect", new object[] { scope.Name })); } try { bool flag2; if (str3 == string.Empty) { connection.SetIsFlexClient(true); flag2 = connection.Connect(scope, serviceCall.Arguments); if (flag2) { string str5; if ((serviceCall.Arguments != null) && (serviceCall.Arguments.Length == 3)) { str5 = serviceCall.Arguments[2] as string; AuthenticationService service = this.Endpoint.GetMessageBroker().GetService("authentication-service") as AuthenticationService; service.Authenticate(str5); } if ((serviceCall.Arguments != null) && (serviceCall.Arguments.Length == 1)) { str5 = serviceCall.Arguments[0] as string; (this.Endpoint.GetMessageBroker().GetService("authentication-service") as AuthenticationService).Authenticate(str5); } } } else { connection.SetIsFlexClient(false); flag2 = connection.Connect(scope, serviceCall.Arguments); } if (flag2) { if (log.get_IsDebugEnabled()) { log.Debug("Connected RtmpClient: " + connection.Client.Id); } serviceCall.Status = 2; if (serviceCall is IPendingServiceCall) { saso2 = StatusASO.GetStatusObject("NetConnection.Connect.Success", connection.ObjectEncoding); saso2.Add("id", connection.Client.Id); (serviceCall as IPendingServiceCall).Result = saso2; } connection.GetChannel(2).Write(new Ping(0, 0, -1)); connection.StartRoundTripMeasurement(); } else { if (log.get_IsDebugEnabled()) { log.Debug("Connect failed"); } serviceCall.Status = 0x12; if (serviceCall is IPendingServiceCall) { (serviceCall as IPendingServiceCall).Result = StatusASO.GetStatusObject("NetConnection.Connect.Rejected", connection.ObjectEncoding); } flag = true; } } catch (ClientRejectedException exception) { if (log.get_IsDebugEnabled()) { log.Debug("Connect rejected"); } serviceCall.Status = 0x12; if (serviceCall is IPendingServiceCall) { saso2 = StatusASO.GetStatusObject("NetConnection.Connect.Rejected", connection.ObjectEncoding); saso2.Application = exception.Reason; (serviceCall as IPendingServiceCall).Result = saso2; } flag = true; } } } } catch (Exception exception5) { exception2 = exception5; if (log.get_IsErrorEnabled()) { log.Error("Error connecting", exception2); } serviceCall.Status = 20; if (serviceCall is IPendingServiceCall) { (serviceCall as IPendingServiceCall).Result = StatusASO.GetStatusObject("NetConnection.Connect.Failed", connection.ObjectEncoding); } flag = true; } break; } case "disconnect": connection.Close(); break; case "createStream": case "deleteStream": case "releaseStream": case "publish": case "play": case "seek": case "pause": case "closeStream": case "receiveVideo": case "receiveAudio": { IStreamService scopeService = ScopeUtils.GetScopeService(connection.Scope, typeof(IStreamService)) as IStreamService; statusObject = null; try { if (!InvokeCall(connection, serviceCall, scopeService)) { statusObject = StatusASO.GetStatusObject("NetStream.InvalidArg", connection.ObjectEncoding); statusObject.description = string.Concat(new object[] { "Failed to ", serviceMethodName, " (stream ID: ", header.StreamId, ")" }); } } catch (Exception exception6) { exception2 = exception6; log.Error("Error while invoking " + serviceMethodName + " on stream service.", exception2); statusObject = StatusASO.GetStatusObject("NetStream.Failed", connection.ObjectEncoding); statusObject.description = string.Concat(new object[] { "Error while invoking ", serviceMethodName, " (stream ID: ", header.StreamId, ")" }); statusObject.details = exception2.Message; } if (statusObject != null) { channel.SendStatus(statusObject); } break; } default: if (connection.IsConnected) { InvokeCall(connection, serviceCall); } else { if (log.get_IsWarnEnabled()) { log.Warn("Not connected, closing connection"); } connection.Close(); } break; } } if (invoke is FlexInvoke) { FlexInvoke message = new FlexInvoke { InvokeId = invoke.InvokeId }; message.SetResponseSuccess(); if (serviceCall is IPendingServiceCall) { IPendingServiceCall call2 = (IPendingServiceCall)serviceCall; message.Response = call2.Result; } channel.Write(message); } else if (invoke is Invoke) { if ((header.StreamId != 0) && ((serviceCall.Status == 4) || (serviceCall.Status == 3))) { if (log.get_IsDebugEnabled()) { log.Debug("Method does not have return value, do not reply"); } return; } Invoke invoke3 = new Invoke { ServiceCall = serviceCall, InvokeId = invoke.InvokeId }; channel.Write(invoke3); } if (flag) { connection.Close(); } if (serviceMethodName == "connect") { connection.Context.ObjectEncoding = connection.ObjectEncoding; } } }