public ChannelEditResult SaveChannel(IChannelInfo channel) { if (channel == null) { throw new ArgumentNullException("channel"); } using (ISession session = Persistance.SessionFactory.OpenSession()) using (ITransaction transaction = session.BeginTransaction(IsolationLevel.Serializable)) { var currentChannel = session.Get <LocalChannelInfo> (channel.ChannelId); if (currentChannel == null) { if (channel.ChannelId != 0) { return(ChannelEditResult.FailedChannelDoesntExist); } currentChannel = new LocalChannelInfo(); } currentChannel.Name = channel.Name; currentChannel.Description = channel.Description; currentChannel.ParentChannelId = channel.ParentChannelId; currentChannel.ReadOnly = channel.ReadOnly; currentChannel.UserLimit = channel.UserLimit; session.SaveOrUpdate(currentChannel); transaction.Commit(); } OnChannelsUpdated(EventArgs.Empty); return(ChannelEditResult.Success); }
public void Move(IUserInfo user, IChannelInfo channel) { if (user == null) { throw new ArgumentNullException("user"); } if (channel == null) { throw new ArgumentNullException("channel"); } IConnection connection = GetConnection(user); if (connection == null) { return; } IUserInfo old; if (!connectedUsers.TryGetKey(connection, out old)) { return; } UserInfo newUser = new UserInfo(old, channel.ChannelId); connectedUsers.Inverse[connection] = newUser; }
public static void Main() { TcpChannel myChannel = new TcpChannel(8085); ChannelServices.RegisterChannel(myChannel); MyServiceClass myService = new MyServiceClass(); // After the channel is registered, register the object // with remoting infrastructure by calling Marshal method. ObjRef myObjRef = RemotingServices.Marshal(myService, "TcpService"); // Get the information contributed by active channel. IChannelInfo myChannelInfo = myObjRef.ChannelInfo; IChannelDataStore myIChannelData; foreach (object myChannelData in myChannelInfo.ChannelData) { if (myChannelData is IChannelDataStore) { myIChannelData = (IChannelDataStore)myChannelData; foreach (string myUri in myIChannelData.ChannelUris) { Console.WriteLine("Channel Uris are -> " + myUri); } // Add custom data. string myKey = "Key1"; myIChannelData[myKey] = "My Data"; Console.WriteLine(myIChannelData[myKey].ToString()); } } }
public ChannelEditResult SaveChannel(IChannelInfo channel) { lock (this.channels) { if (GetChannels().Any(c => c.Name.ToLower().Trim() == channel.Name.ToLower().Trim())) { return(ChannelEditResult.FailedChannelExists); } if (channel.ChannelId.Equals(0)) { int id = Interlocked.Increment(ref this.lastId); channels.Add(id, new ChannelInfo(id, channel)); } else if (channels.ContainsKey(channel.ChannelId)) { channels[channel.ChannelId] = new ChannelInfo(channel); } else { return(ChannelEditResult.FailedChannelDoesntExist); } } OnChannelsUpdated(EventArgs.Empty); return(ChannelEditResult.Success); }
public void AddChannel(IChannelInfo channel) { if (channel == null) { return; } if (this.InvokeRequired) { this.BeginInvoke((Action <ChannelInfo>) this.AddChannel, channel); return; } var parent = this.serverNode.Nodes; if (channel.ParentChannelId != 0) { var pair = channelNodes.FirstOrDefault(kvp => kvp.Key.ChannelId == channel.ParentChannelId); if (!pair.Equals(default(KeyValuePair <ChannelInfo, TreeNode>))) { parent = pair.Value.Nodes; } } var node = parent.Add(channel.ChannelId.ToString(), channel.Name); node.Tag = channel; node.ImageKey = "channel"; node.SelectedImageKey = "channel"; SetupChannelContext(node); this.channelNodes.Add(channel, node); }
internal void ChannelEditMessage(MessageEventArgs <ChannelEditMessage> e) { var msg = (ChannelEditMessage)e.Message; ChannelEditResult result = ChannelEditResult.FailedUnknown; if (msg.Channel.ChannelId != 0) { List <IChannelInfo> channels = context.ChannelsProvider.GetChannels().ToList(); IChannelInfo realChannel = channels.FirstOrDefault(c => c.ChannelId == msg.Channel.ChannelId); if (realChannel == null) { result = ChannelEditResult.FailedChannelDoesntExist; } else if (msg.Delete && channels.Count == 1) { result = ChannelEditResult.FailedLastChannel; } else if (!this.context.ChannelsProvider.UpdateSupported) { result = ChannelEditResult.FailedChannelsReadOnly; } else if (realChannel.ReadOnly) { result = ChannelEditResult.FailedChannelReadOnly; } else if (msg.Channel.ChannelId != 0) { if (msg.Delete && !context.GetPermission(PermissionName.DeleteChannel, msg.Channel, e.Connection)) { result = ChannelEditResult.FailedPermissions; } else if (!msg.Delete && !context.GetPermission(PermissionName.EditChannel, msg.Channel, e.Connection)) { result = ChannelEditResult.FailedPermissions; } } } else if (!context.GetPermission(PermissionName.AddChannel, e.Connection)) { result = ChannelEditResult.FailedPermissions; } if (result == ChannelEditResult.FailedUnknown) { if (!msg.Delete) { result = this.context.ChannelsProvider.SaveChannel(msg.Channel); } else { result = this.context.ChannelsProvider.DeleteChannel(msg.Channel); } } e.Connection.SendAsync(new ChannelEditResultMessage(msg.Channel, result)); }
public ChannelEditMessage(IChannelInfo channel) : this() { if (channel == null) throw new ArgumentNullException ("channel"); this.channel = new ChannelInfo (channel); }
public void Update(int siteId, IChannelInfo channelInfo) { if (channelInfo == null) { return; } DataProvider.ChannelDao.Update((ChannelInfo)channelInfo); }
private void AddChannels(IEnumerable <IChannelInfo> channels, IChannelInfo parent) { foreach (var c in channels.Where(c => c.ParentChannelId == parent.ChannelId)) { this.AddChannel(c); this.AddChannels(channels, c); } }
protected ObjRef(SerializationInfo info, StreamingContext context) { SerializationInfoEnumerator en = info.GetEnumerator(); // Info to serialize: uri, objrefFlags, typeInfo, envoyInfo, channelInfo bool marshalledValue = true; while (en.MoveNext()) { switch (en.Name) { case "uri": uri = (string)en.Value; break; case "typeInfo": typeInfo = (IRemotingTypeInfo)en.Value; break; case "channelInfo": channel_info = (IChannelInfo)en.Value; break; case "envoyInfo": envoyInfo = (IEnvoyInfo)en.Value; break; case "fIsMarshalled": int status; Object o = en.Value; if (o is string) { status = ((IConvertible)o).ToInt32(null); } else { status = (int)o; } if (status == 0) { marshalledValue = false; } break; case "objrefFlags": flags = Convert.ToInt32(en.Value); break; default: throw new NotSupportedException(); } } if (marshalledValue) { flags |= MarshalledObjectRef; } }
protected ObjRef(SerializationInfo info, StreamingContext context) { string str = (string)null; bool flag = false; SerializationInfoEnumerator enumerator = info.GetEnumerator(); while (enumerator.MoveNext()) { if (enumerator.Name.Equals("uri")) { this.uri = (string)enumerator.Value; } else if (enumerator.Name.Equals("typeInfo")) { this.typeInfo = (IRemotingTypeInfo)enumerator.Value; } else if (enumerator.Name.Equals("envoyInfo")) { this.envoyInfo = (IEnvoyInfo)enumerator.Value; } else if (enumerator.Name.Equals("channelInfo")) { this.channelInfo = (IChannelInfo)enumerator.Value; } else if (enumerator.Name.Equals("objrefFlags")) { object obj = enumerator.Value; this.objrefFlags = !(obj.GetType() == typeof(string)) ? (int)obj : ((IConvertible)obj).ToInt32((IFormatProvider)null); } else if (enumerator.Name.Equals("fIsMarshalled")) { object obj = enumerator.Value; if ((!(obj.GetType() == typeof(string)) ? (int)obj : ((IConvertible)obj).ToInt32((IFormatProvider)null)) == 0) { flag = true; } } else if (enumerator.Name.Equals("url")) { str = (string)enumerator.Value; } else if (enumerator.Name.Equals("SrvIdentity")) { this.SetServerIdentity((GCHandle)enumerator.Value); } else if (enumerator.Name.Equals("DomainId")) { this.SetDomainID((int)enumerator.Value); } } this.objrefFlags = flag ? this.objrefFlags & -2 : this.objrefFlags | 1; if (str == null) { return; } this.uri = str; this.objrefFlags = this.objrefFlags | 4; }
internal ObjRef (ObjRef o, bool unmarshalAsProxy) { channel_info = o.channel_info; uri = o.uri; typeInfo = o.typeInfo; envoyInfo = o.envoyInfo; flags = o.flags; if (unmarshalAsProxy) flags |= MarshalledObjectRef; }
public static void AssertChanelsAreEqual(IChannelInfo expected, IChannelInfo actual) { Assert.AreEqual (expected.ChannelId, actual.ChannelId); Assert.AreEqual (expected.ParentChannelId, actual.ParentChannelId); Assert.AreEqual (expected.Name, actual.Name); Assert.AreEqual (expected.Description, actual.Description); Assert.AreEqual (expected.ReadOnly, actual.ReadOnly); Assert.AreEqual (expected.UserLimit, actual.UserLimit); }
public static void AssertChanelsAreEqual(IChannelInfo expected, IChannelInfo actual) { Assert.AreEqual(expected.ChannelId, actual.ChannelId); Assert.AreEqual(expected.ParentChannelId, actual.ParentChannelId); Assert.AreEqual(expected.Name, actual.Name); Assert.AreEqual(expected.Description, actual.Description); Assert.AreEqual(expected.ReadOnly, actual.ReadOnly); Assert.AreEqual(expected.UserLimit, actual.UserLimit); }
/// <summary>Initializes a new instance of the <see cref="T:System.Runtime.Remoting.ObjRef" /> class from serialized data.</summary> /// <param name="info">The object that holds the serialized object data. </param> /// <param name="context">The contextual information about the source or destination of the exception. </param> protected ObjRef(SerializationInfo info, StreamingContext context) { SerializationInfoEnumerator enumerator = info.GetEnumerator(); bool flag = true; while (enumerator.MoveNext()) { string name = enumerator.Name; switch (name) { case "uri": this.uri = (string)enumerator.Value; continue; case "typeInfo": this.typeInfo = (IRemotingTypeInfo)enumerator.Value; continue; case "channelInfo": this.channel_info = (IChannelInfo)enumerator.Value; continue; case "envoyInfo": this.envoyInfo = (IEnvoyInfo)enumerator.Value; continue; case "fIsMarshalled": { object value = enumerator.Value; int num2; if (value is string) { num2 = ((IConvertible)value).ToInt32(null); } else { num2 = (int)value; } if (num2 == 0) { flag = false; } continue; } case "objrefFlags": this.flags = Convert.ToInt32(enumerator.Value); continue; } throw new NotSupportedException(); } if (flag) { this.flags |= ObjRef.MarshalledObjectRef; } }
internal ObjRef(Type type, string url, object remoteChannelData) { this.uri = url; this.typeInfo = new TypeInfo(type); if (remoteChannelData != null) { this.channel_info = new ChannelInfo(remoteChannelData); } this.flags |= ObjRef.WellKnowObjectRef; }
// shallow copy constructor used for smuggling. private ObjRef(ObjRef o) { BCLDebug.Assert(o.GetType() == typeof(ObjRef), "this should be just an ObjRef"); uri = o.uri; typeInfo = o.typeInfo; envoyInfo = o.envoyInfo; channelInfo = o.channelInfo; objrefFlags = o.objrefFlags; } // ObjRef
public ChannelEditMessage(IChannelInfo channel) : this() { if (channel == null) { throw new ArgumentNullException("channel"); } this.channel = new ChannelInfo(channel); }
private ObjRef(ObjRef o) { this.uri = o.uri; this.typeInfo = o.typeInfo; this.envoyInfo = o.envoyInfo; this.channelInfo = o.channelInfo; this.objrefFlags = o.objrefFlags; this.SetServerIdentity(o.GetServerIdentity()); this.SetDomainID(o.GetDomainID()); }
public ChannelChangedEventArgs(IUserInfo target, IChannelInfo targetChannel, IChannelInfo previousChannel, IUserInfo movedBy) : base(target) { if (targetChannel == null) throw new ArgumentNullException ("targetChannel"); this.TargetChannel = targetChannel; this.MovedBy = movedBy; this.PreviousChannel = previousChannel; }
private ObjRef(ObjRef o) { this.uri = o.uri; this.typeInfo = o.typeInfo; this.envoyInfo = o.envoyInfo; this.channelInfo = o.channelInfo; this.objrefFlags = o.objrefFlags; this.SetServerIdentity(o.GetServerIdentity()); this.SetDomainID(o.GetDomainID()); }
/// <summary> /// Erzeugt eine neue Zugriffsinstanz. /// </summary> /// <param name="main">Die zugehörige Anwendung.</param> /// <param name="replayPath">Pfad zu einer VCR.NET Aufzeichnungsdatei.</param> public VCRAdaptor(IViewerSite main, string replayPath) : base(main) { // Connect to alternate interfaces ChannelInfo = (IChannelInfo)main; StreamInfo = (IStreamInfo)main; // Remember m_Profile = RemoteInfo.VCRProfile; // Use default if (string.IsNullOrEmpty(m_Profile)) { m_Profile = "*"; } // Construct Url Uri uri = RemoteInfo.ServerUri; // Connect to stream Connect(StreamInfo.BroadcastIP, StreamInfo.BroadcastPort, uri.Host); // Check startup mode if (string.IsNullOrEmpty(replayPath)) { // Special if LIVE is active var current = VCRNETRestProxy.GetFirstActivityForProfile(EndPoint, Profile); if (current != null) { if (!current.IsActive) { current = null; } else if ("LIVE".Equals(current.name)) { current = null; } } // Start correct access module if (current == null) { StartLIVE(true); } else { StartWatch(null, true); } } else { // Start remote file replay StartReplay(replayPath, null, null, true); } }
public ChannelChangedEventArgs(IUserInfo target, IChannelInfo targetChannel, IChannelInfo previousChannel, IUserInfo movedBy) : base(target) { if (targetChannel == null) { throw new ArgumentNullException("targetChannel"); } this.TargetChannel = targetChannel; this.MovedBy = movedBy; this.PreviousChannel = previousChannel; }
internal ObjRef(Type type, string url, object remoteChannelData) { uri = url; typeInfo = new TypeInfo(type); if (remoteChannelData != null) { channel_info = new ChannelInfo(remoteChannelData); } flags |= WellKnowObjectRef; }
public ChannelForm(IChannelInfo channel) { InitializeComponent (); this.Channel = new ChannelInfo (channel.ChannelId, channel); this.Text = "Edit Channel"; this.Icon = Resources.ChannelEditImage.ToIcon(); this.inName.Text = channel.Name; this.inDescription.Text = channel.Description; this.inUserLimit.Value = channel.UserLimit; }
public ChannelForm(IChannelInfo channel) { InitializeComponent(); this.Channel = new ChannelInfo(channel.ChannelId, channel); this.Text = "Edit Channel"; this.Icon = Resources.ChannelEditImage.ToIcon(); this.inName.Text = channel.Name; this.inDescription.Text = channel.Description; this.inUserLimit.Value = channel.UserLimit; }
internal ObjRef(ObjRef o, bool unmarshalAsProxy) { this.channel_info = o.channel_info; this.uri = o.uri; this.typeInfo = o.typeInfo; this.envoyInfo = o.envoyInfo; this.flags = o.flags; if (unmarshalAsProxy) { this.flags |= ObjRef.MarshalledObjectRef; } }
// shallow copy constructor used for smuggling. private ObjRef(ObjRef o) { BCLDebug.Assert(o.GetType() == typeof(ObjRef), "this should be just an ObjRef"); uri = o.uri; typeInfo = o.typeInfo; envoyInfo = o.envoyInfo; channelInfo = o.channelInfo; objrefFlags = o.objrefFlags; SetServerIdentity(o.GetServerIdentity()); SetDomainID(o.GetDomainID()); } // ObjRef
public ChannelListMessage(IEnumerable<IChannelInfo> channels, IChannelInfo defaultChannel) : this() { if (channels == null) throw new ArgumentNullException ("channels"); if (defaultChannel == null) throw new ArgumentNullException ("defaultChannel"); Channels = channels; DefaultChannelId = defaultChannel.ChannelId; Result = GenericResult.Success; }
internal ObjRef(ObjRef o, bool unmarshalAsProxy) { channel_info = o.channel_info; uri = o.uri; typeInfo = o.typeInfo; envoyInfo = o.envoyInfo; flags = o.flags; if (unmarshalAsProxy) { flags |= MarshalledObjectRef; } }
/// <summary> /// Requests to move <paramref name="user"/> to <paramref name="targetChannel"/>. /// </summary> /// <param name="user">The user to move.</param> /// <param name="targetChannel">The target channel to move the user to.</param> public void Move(IUserInfo user, IChannelInfo targetChannel) { if (user == null) { throw new ArgumentNullException("user"); } if (targetChannel == null) { throw new ArgumentNullException("targetChannel"); } this.context.Connection.SendAsync(new ChannelChangeMessage(user.UserId, targetChannel.ChannelId)); }
public static void BeginCapture(this IAudioEngine self, AudioSource source, IChannelInfo channel) { if (self == null) { throw new ArgumentNullException("self"); } if (channel == null) { throw new ArgumentNullException("channel"); } self.BeginCapture(source, new[] { channel }); }
internal ObjRef(Type type, string url, object remoteChannelData) { uri = url; typeInfo = new TypeInfo(type); #if !DISABLE_REMOTING if (remoteChannelData != null) { channel_info = new ChannelInfo(remoteChannelData); } #endif flags |= WellKnowObjectRef; }
public void Move(IUserInfo user, IChannelInfo channel) { if (user == null) { throw new ArgumentNullException("user"); } if (channel == null) { throw new ArgumentNullException("channel"); } int previousChannel = user.CurrentChannelId; if (previousChannel == channel.ChannelId) { return; } IUserInfo realUser = this[user.UserId]; if (realUser == null) { return; } IChannelInfo realChannel = context.Channels[channel.ChannelId]; if (realChannel == null) { return; } var changeInfo = new ChannelChangeInfo(user.UserId, channel.ChannelId, previousChannel); int numUsers = context.Users.Count(u => u.CurrentChannelId == channel.ChannelId); if (channel.UserLimit != 0 && numUsers >= channel.UserLimit) { return; } Manager.Move(realUser, realChannel); foreach (var connection in Manager.GetConnections()) { connection.SendAsync(new UserChangedChannelMessage { ChangeInfo = changeInfo }); } }
public ChannelInfo(int channelId, IChannelInfo channelInfo) : this(channelId) { if (channelInfo == null) { throw new ArgumentNullException("channelInfo"); } ParentChannelId = channelInfo.ParentChannelId; Name = channelInfo.Name; Description = channelInfo.Description; UserLimit = channelInfo.UserLimit; ReadOnly = channelInfo.ReadOnly; }
public ChannelEditResult DeleteChannel(IChannelInfo channel) { ChannelEditResult result; lock (this.channels) { if (!this.channels.Remove(channel.ChannelId)) { return(ChannelEditResult.FailedChannelDoesntExist); } } OnChannelsUpdated(EventArgs.Empty); return(ChannelEditResult.Success); }
public ChannelListMessage(IEnumerable <IChannelInfo> channels, IChannelInfo defaultChannel) : this() { if (channels == null) { throw new ArgumentNullException("channels"); } if (defaultChannel == null) { throw new ArgumentNullException("defaultChannel"); } Channels = channels; DefaultChannelId = defaultChannel.ChannelId; Result = GenericResult.Success; }
/// <summary> /// Erzeugt eine neue Zugriffsinstanz. /// </summary> /// <param name="main">Die zugehörige Anwendung.</param> /// <param name="streamIndex">Teilaufzeichnung, die betrachtet werden soll.</param> /// <param name="timeshift">Gesetzt, wenn der Timeshift Modus aktiviert werden soll.</param> public VCRAdaptor( IViewerSite main, int streamIndex, bool timeshift ) : base( main ) { // Connect to alternate interfaces ChannelInfo = (IChannelInfo) main; StreamInfo = (IStreamInfo) main; // Remember m_Profile = RemoteInfo.VCRProfile; // Use default if (string.IsNullOrEmpty( m_Profile )) m_Profile = "*"; // Construct Url var uri = RemoteInfo.ServerUri; // Connect to stream Connect( StreamInfo.BroadcastIP, StreamInfo.BroadcastPort, uri.Host ); // Find all current activities var activities = VCRNETRestProxy.GetActivitiesForProfile( EndPoint, Profile ); if (activities.Count < 1) StartLIVE( true ); else { // Find the activity var current = activities.FirstOrDefault( activity => activity.streamIndex == streamIndex ); if (current == null) StartWatch( null, true ); else if (timeshift && string.IsNullOrEmpty( StreamInfo.BroadcastIP ) && (current.files.Length > 0)) StartReplay( current.files[0], current.name, current, true ); else StartWatch( string.Format( "dvbnet:{0}", streamIndex ), true ); } }
[System.Security.SecurityCritical] // auto-generated internal void Init(Object o, Identity idObj, RuntimeType requestedType) { Message.DebugOut("RemotingServices::FillObjRef: IN"); BCLDebug.Assert(idObj != null,"idObj != null"); // Set the URI of the object to be marshaled uri = idObj.URI; // Figure out the type MarshalByRefObject obj = idObj.TPOrObject; BCLDebug.Assert(null != obj, "Identity not setup correctly"); // Get the type of the object RuntimeType serverType = null; if(!RemotingServices.IsTransparentProxy(obj)) { serverType = (RuntimeType)obj.GetType(); } else { serverType = (RuntimeType)RemotingServices.GetRealProxy(obj).GetProxiedType(); } RuntimeType typeOfObj = (null == requestedType ? serverType : requestedType); // Make sure that the server and requested types are compatible // (except for objects that implement IMessageSink, since we // just hand off the message instead of invoking the proxy) if ((null != requestedType) && !requestedType.IsAssignableFrom(serverType) && (!typeof(IMessageSink).IsAssignableFrom(serverType))) { throw new RemotingException( String.Format( CultureInfo.CurrentCulture, Environment.GetResourceString( "Remoting_InvalidRequestedType"), requestedType.ToString())); ; } #if FEATURE_COMINTEROP // Create the type info if(serverType.IsCOMObject) { // __ComObjects need dynamic TypeInfo DynamicTypeInfo dt = new DynamicTypeInfo(typeOfObj); TypeInfo = (IRemotingTypeInfo) dt; } else #endif // FEATURE_COMINTEROP { RemotingTypeCachedData cache = (RemotingTypeCachedData) InternalRemotingServices.GetReflectionCachedData(typeOfObj); TypeInfo = (IRemotingTypeInfo)cache.TypeInfo; } if (!idObj.IsWellKnown()) { // Create the envoy info EnvoyInfo = System.Runtime.Remoting.EnvoyInfo.CreateEnvoyInfo(idObj as ServerIdentity); // Create the channel info IChannelInfo chan = (IChannelInfo)new ChannelInfo(); // Make sure the channelInfo only has x-appdomain data since the objref is agile while other // channelData might not be and regardless this data is useless for an appdomain proxy if (o is AppDomain){ Object[] channelData = chan.ChannelData; int channelDataLength = channelData.Length; Object[] newChannelData = new Object[channelDataLength]; // Clone the data so that we dont [....] the current appdomain data which is stored // as a static Array.Copy(channelData, newChannelData, channelDataLength); for (int i = 0; i < channelDataLength; i++) { if (!(newChannelData[i] is CrossAppDomainData)) newChannelData[i] = null; } chan.ChannelData = newChannelData; } ChannelInfo = chan; if (serverType.HasProxyAttribute) { SetHasProxyAttribute(); } } else { SetWellKnown(); } // See if we should and can use a url obj ref? if (ShouldUseUrlObjRef()) { if (IsWellKnown()) { // full uri already supplied. SetObjRefLite(); } else { String httpUri = ChannelServices.FindFirstHttpUrlForObject(URI); if (httpUri != null) { URI = httpUri; SetObjRefLite(); } } } } // Init
[System.Security.SecurityCritical] // auto-generated private ObjRef(ObjRef o) { BCLDebug.Assert(o.GetType() == typeof(ObjRef), "this should be just an ObjRef"); uri = o.uri; typeInfo = o.typeInfo; envoyInfo = o.envoyInfo; channelInfo = o.channelInfo; objrefFlags = o.objrefFlags; SetServerIdentity(o.GetServerIdentity()); SetDomainID(o.GetDomainID()); } // ObjRef
public void Move (IUserInfo user, IChannelInfo channel) { if (user == null) throw new ArgumentNullException ("user"); if (channel == null) throw new ArgumentNullException ("channel"); int previousChannel = user.CurrentChannelId; if (previousChannel == channel.ChannelId) return; IUserInfo realUser = this[user.UserId]; if (realUser == null) return; IChannelInfo realChannel = context.Channels[channel.ChannelId]; if (realChannel == null) return; var changeInfo = new ChannelChangeInfo (user.UserId, channel.ChannelId, previousChannel); int numUsers = context.Users.Count (u => u.CurrentChannelId == channel.ChannelId); if (channel.UserLimit != 0 && numUsers >= channel.UserLimit) return; Manager.Move (realUser, realChannel); foreach (var connection in Manager.GetConnections()) connection.SendAsync (new UserChangedChannelMessage { ChangeInfo = changeInfo }); }
public ChannelEditResult SaveChannel(IChannelInfo channel) { lock (this.channels) { if (GetChannels().Any (c => c.Name.ToLower().Trim() == channel.Name.ToLower().Trim())) return ChannelEditResult.FailedChannelExists; if (channel.ChannelId.Equals (0)) { int id = Interlocked.Increment (ref this.lastId); channels.Add (id, new ChannelInfo (id, channel)); } else if (channels.ContainsKey (channel.ChannelId)) channels[channel.ChannelId] = new ChannelInfo (channel); else return ChannelEditResult.FailedChannelDoesntExist; } OnChannelsUpdated (EventArgs.Empty); return ChannelEditResult.Success; }
// shallow copy constructor used for smuggling. private ObjRef(ObjRef o) { BCLDebug.Assert(o.GetType() == typeof(ObjRef), "this should be just an ObjRef"); uri = o.uri; typeInfo = o.typeInfo; envoyInfo = o.envoyInfo; channelInfo = o.channelInfo; objrefFlags = o.objrefFlags; } // ObjRef
public static void BeginCapture(this IAudioEngine self, AudioSource source, IChannelInfo channel) { if (self == null) throw new ArgumentNullException ("self"); if (channel == null) throw new ArgumentNullException ("channel"); self.BeginCapture (source, new[] { channel }); }
/// <summary> /// Requests to move <paramref name="user"/> to <paramref name="targetChannel"/>. /// </summary> /// <param name="user">The user to move.</param> /// <param name="targetChannel">The target channel to move the user to.</param> public void Move(IUserInfo user, IChannelInfo targetChannel) { if (user == null) throw new ArgumentNullException ("user"); if (targetChannel == null) throw new ArgumentNullException ("targetChannel"); this.context.Connection.SendAsync (new ChannelChangeMessage (user.UserId, targetChannel.ChannelId)); }
internal ObjRef (string typeName, string uri, IChannelInfo cinfo) { this.uri = uri; channel_info = cinfo; typeInfo = new TypeInfo (Type.GetType (typeName, true)); }
public ChannelEditResult DeleteChannel(IChannelInfo channel) { ChannelEditResult result; lock (this.channels) { if (!this.channels.Remove (channel.ChannelId)) return ChannelEditResult.FailedChannelDoesntExist; } OnChannelsUpdated (EventArgs.Empty); return ChannelEditResult.Success; }
// // internal void Init(Identity idObj, Type requestedType) { Message.DebugOut("RemotingServices::FillObjRef: IN"); BCLDebug.Assert(idObj != null,"idObj != null"); // Set the URI of the object to be marshaled URI = idObj.URI; // Figure out the type MarshalByRefObject obj = idObj.TPOrObject; BCLDebug.Assert(null != obj, "Identity not setup correctly"); // Get the type of the object Type serverType = null; if(!RemotingServices.IsTransparentProxy(obj)) { serverType = obj.GetType(); } else { serverType = RemotingServices.GetRealProxy(obj).GetProxiedType(); } Type typeOfObj = (null == requestedType ? serverType : requestedType); // Make sure that the server and requested types are compatible // (except for objects that implement IMessageSink, since we // just hand off the message instead of invoking the proxy) if ((null != requestedType) && !requestedType.IsAssignableFrom(serverType) && (!typeof(IMessageSink).IsAssignableFrom(serverType))) { throw new RemotingException( String.Format( Environment.GetResourceString( "Remoting_InvalidRequestedType"), requestedType.ToString())); ; } { RemotingTypeCachedData cache = (RemotingTypeCachedData) InternalRemotingServices.GetReflectionCachedData(typeOfObj); TypeInfo = (IRemotingTypeInfo)cache.TypeInfo; } if (!idObj.IsWellKnown()) { // Create the envoy info EnvoyInfo = System.Runtime.Remoting.EnvoyInfo.CreateEnvoyInfo(idObj as ServerIdentity); // Create the channel info ChannelInfo = (IChannelInfo)new ChannelInfo(); if (serverType.HasProxyAttribute) { SetHasProxyAttribute(); } } else { SetWellKnown(); } // See if we should and can use a url obj ref? if (ShouldUseUrlObjRef()) { if (IsWellKnown()) { // full uri already supplied. SetObjRefLite(); } else { String httpUri = ChannelServices.FindFirstHttpUrlForObject(URI); if (httpUri != null) { URI = httpUri; SetObjRefLite(); } } } } // Init
public void AddChannel (IChannelInfo channel) { if (channel == null) return; if (this.InvokeRequired) { this.BeginInvoke ((Action<ChannelInfo>)this.AddChannel, channel); return; } var parent = this.serverNode.Nodes; if (channel.ParentChannelId != 0) { var pair = channelNodes.FirstOrDefault (kvp => kvp.Key.ChannelId == channel.ParentChannelId); if (!pair.Equals (default(KeyValuePair<ChannelInfo, TreeNode>))) parent = pair.Value.Nodes; } var node = parent.Add (channel.ChannelId.ToString(), channel.Name); node.Tag = channel; node.ImageKey = "channel"; node.SelectedImageKey = "channel"; SetupChannelContext (node); this.channelNodes.Add (channel, node); }
internal void UpdateChannelInfo() { channel_info = new ChannelInfo (); }
internal ObjRef (Type type, string url, object remoteChannelData) { uri = url; typeInfo = new TypeInfo(type); if (remoteChannelData != null) channel_info = new ChannelInfo (remoteChannelData); flags |= WellKnowObjectRef; }
protected ObjRef (SerializationInfo info, StreamingContext context) { SerializationInfoEnumerator en = info.GetEnumerator(); // Info to serialize: uri, objrefFlags, typeInfo, envoyInfo, channelInfo bool marshalledValue = true; while (en.MoveNext ()) { switch (en.Name) { case "uri": uri = (string)en.Value; break; case "typeInfo": typeInfo = (IRemotingTypeInfo)en.Value; break; case "channelInfo": channel_info = (IChannelInfo)en.Value; break; case "envoyInfo": envoyInfo = (IEnvoyInfo)en.Value; break; case "fIsMarshalled": int status; Object o = en.Value; if (o is string) status = ((IConvertible) o).ToInt32(null); else status = (int) o; if (status == 0) marshalledValue = false; break; case "objrefFlags": flags = Convert.ToInt32 (en.Value); break; default: throw new NotSupportedException (); } } if (marshalledValue) flags |= MarshalledObjectRef; }
private void AddChannels (IEnumerable<IChannelInfo> channels, IChannelInfo parent) { foreach (var c in channels.Where (c => c.ParentChannelId == parent.ChannelId)) { this.AddChannel (c); this.AddChannels (channels, c); } }
protected ObjRef(SerializationInfo info, StreamingContext context) { string str = null; bool flag = false; SerializationInfoEnumerator enumerator = info.GetEnumerator(); while (enumerator.MoveNext()) { if (enumerator.Name.Equals("uri")) { this.uri = (string) enumerator.Value; } else { if (enumerator.Name.Equals("typeInfo")) { this.typeInfo = (IRemotingTypeInfo) enumerator.Value; continue; } if (enumerator.Name.Equals("envoyInfo")) { this.envoyInfo = (IEnvoyInfo) enumerator.Value; continue; } if (enumerator.Name.Equals("channelInfo")) { this.channelInfo = (IChannelInfo) enumerator.Value; continue; } if (enumerator.Name.Equals("objrefFlags")) { object obj2 = enumerator.Value; if (obj2.GetType() == typeof(string)) { this.objrefFlags = ((IConvertible) obj2).ToInt32(null); } else { this.objrefFlags = (int) obj2; } continue; } if (enumerator.Name.Equals("fIsMarshalled")) { int num; object obj3 = enumerator.Value; if (obj3.GetType() == typeof(string)) { num = ((IConvertible) obj3).ToInt32(null); } else { num = (int) obj3; } if (num == 0) { flag = true; } continue; } if (enumerator.Name.Equals("url")) { str = (string) enumerator.Value; } else { if (enumerator.Name.Equals("SrvIdentity")) { this.SetServerIdentity((GCHandle) enumerator.Value); continue; } if (enumerator.Name.Equals("DomainId")) { this.SetDomainID((int) enumerator.Value); } } } } if (!flag) { this.objrefFlags |= 1; } else { this.objrefFlags &= -2; } if (str != null) { this.uri = str; this.objrefFlags |= 4; } }
/// <summary> /// Erzeugte eine neue Zugriffsinstanz. /// </summary> /// <param name="profile">Zu verwendende DVB.NET Hardware Abstraktion.</param> /// <param name="main">Zugehörige Anwendung.</param> public DeviceAdpator( Profile profile, IViewerSite main ) : base( main ) { // Remember Profile = profile; // Attach to the device Device = HardwareManager.OpenHardware( Profile ); // Create m_TTXConnector = new TTXStreamConsumer( this ); // Load alternate interfaces GeneralInfo = (IGeneralInfo) main; ChannelInfo = (IChannelInfo) main; StreamInfo = (IStreamInfo) main; LocalInfo = (ILocalInfo) main; // Initialize core - DirectShow Graph feed directly from a Transport Stream SetAccessor( new AudioVideoAccessor() ); }
public void Move (IConnection mover, IUserInfo user, IChannelInfo channel) { if (mover == null) throw new ArgumentNullException ("mover"); if (user == null) throw new ArgumentNullException ("user"); if (channel == null) throw new ArgumentNullException ("channel"); IUserInfo movingUser = this.context.Users[mover]; int moverId = (movingUser != null) ? movingUser.UserId : 0; MoveUser (moverId, user.UserId, channel.ChannelId); }
/// <include file='doc\ObjRef.uex' path='docs/doc[@for="ObjRef.ObjRef2"]/*' /> protected ObjRef(SerializationInfo info, StreamingContext context) { String url = null; // an objref lite url bool bFoundFIsMarshalled = false; SerializationInfoEnumerator e = info.GetEnumerator(); while (e.MoveNext()) { if (e.Name.Equals("uri")) { uri = (String) e.Value; } else if (e.Name.Equals("typeInfo")) { typeInfo = (IRemotingTypeInfo) e.Value; } else if (e.Name.Equals("envoyInfo")) { envoyInfo = (IEnvoyInfo) e.Value; } else if (e.Name.Equals("channelInfo")) { channelInfo = (IChannelInfo) e.Value; } else if (e.Name.Equals("objrefFlags")) { Object o = e.Value; if(o.GetType() == typeof(String)) { objrefFlags = ((IConvertible)o).ToInt32(null); } else { objrefFlags = (int)o; } } else if (e.Name.Equals("fIsMarshalled")) { int value; Object o = e.Value; if(o.GetType() == typeof(String)) value = ((IConvertible)o).ToInt32(null); else value = (int)o; if (value == 0) bFoundFIsMarshalled = true; } else if (e.Name.Equals("url")) { url = (String)e.Value; } } if (!bFoundFIsMarshalled) { // This ObjRef was not passed as a parameter, so we need to unmarshal it. objrefFlags |= FLG_MARSHALED_OBJECT; } // If only url is present, then it is an ObjRefLite. if (url != null) { uri = url; objrefFlags |= FLG_LITE_OBJREF; } } // ObjRef .ctor
public ChannelInfo(int channelId, IChannelInfo channelInfo) : this(channelId) { if (channelInfo == null) throw new ArgumentNullException ("channelInfo"); ParentChannelId = channelInfo.ParentChannelId; Name = channelInfo.Name; Description = channelInfo.Description; UserLimit = channelInfo.UserLimit; ReadOnly = channelInfo.ReadOnly; }
internal ObjRef (string uri, IChannelInfo cinfo) { this.uri = uri; this.channel_info = cinfo; }
/// <summary> /// Erzeugt eine neue Zugriffsinstanz. /// </summary> /// <param name="main">Die zugehörige Anwendung.</param> /// <param name="replayPath">Pfad zu einer VCR.NET Aufzeichnungsdatei.</param> public VCRAdaptor( IViewerSite main, string replayPath ) : base( main ) { // Connect to alternate interfaces ChannelInfo = (IChannelInfo) main; StreamInfo = (IStreamInfo) main; // Remember m_Profile = RemoteInfo.VCRProfile; // Use default if (string.IsNullOrEmpty( m_Profile )) m_Profile = "*"; // Construct Url Uri uri = RemoteInfo.ServerUri; // Connect to stream Connect( StreamInfo.BroadcastIP, StreamInfo.BroadcastPort, uri.Host ); // Check startup mode if (string.IsNullOrEmpty( replayPath )) { // Special if LIVE is active var current = VCRNETRestProxy.GetFirstActivityForProfile( EndPoint, Profile ); if (current != null) if (!current.IsActive) current = null; else if ("LIVE".Equals( current.name )) current = null; // Start correct access module if (current == null) StartLIVE( true ); else StartWatch( null, true ); } else { // Start remote file replay StartReplay( replayPath, null, null, true ); } }