private static void UpdateChannelStateUser(IUser user, ChannelState chState, int channelId) { ChannelState currentChState; bool stateExists = user.ChannelStates.TryGetValue(channelId, out currentChState); if (stateExists) { if (chState == ChannelState.nottunable) { return; } bool recording = (currentChState == ChannelState.recording); if (!recording) { user.ChannelStates[channelId] = chState; //add key if does not exist, or update existing one. } } else { user.ChannelStates[channelId] = chState; //add key if does not exist, or update existing one. } }
public void WatchConnectivityState(ChannelState lastObservedState, Timespec deadline, CompletionQueueSafeHandle cq, CompletionRegistry completionRegistry, BatchCompletionDelegate callback) { var ctx = BatchContextSafeHandle.Create(); completionRegistry.RegisterBatchCompletion(ctx, callback); Native.grpcsharp_channel_watch_connectivity_state(this, lastObservedState, deadline, cq, ctx); }
public void StateChanged(ChannelState state) { this.state = state; if (OnStateChanged != null) OnStateChanged(); }
public void Close() { state = ChannelState.Closing; Closing?.Invoke(null, new ClosingArgs { Channel = this }); Flush(); }
public ChannelStateChange(ChannelEvent e, ChannelState state, ChannelState previous, ErrorInfo error = null, bool resumed = false) { Event = e; Previous = previous; Current = state; Error = error; Resumed = resumed; }
/// <summary> /// Remove the data channel from the peer connection and destroy it. /// </summary> public void Dispose() { State = ChannelState.Closing; PeerConnection.RemoveDataChannel(this); State = ChannelState.Closed; _handle.Free(); GC.SuppressFinalize(this); }
public void WatchConnectivityState(ChannelState lastObservedState, Timespec deadline, CompletionQueueSafeHandle cq, CompletionRegistry completionRegistry, BatchCompletionDelegate callback) { var ctx = BatchContextSafeHandle.Create(); completionRegistry.RegisterBatchCompletion(ctx, callback); grpcsharp_channel_watch_connectivity_state(this, lastObservedState, deadline, cq, ctx); }
public static ChannelFactorySyntax.ITransportSyntax WebSocketTransport(this ChannelFactorySyntax.IRealmSyntax realmSyntax, string address) { ChannelState state = realmSyntax.State; state.ConnectionActivator = new MessageWebSocketActivator(address); return(state); }
public override async Task OpenAsync() { State = ChannelState.Connecting; readConnection = new SemaphoreSlim(1); writeConnection = new SemaphoreSlim(1); localStream = client.GetStream(); if (pskManager != null) { try { protocol = client.ConnectPskTlsServer(pskManager, localStream); stream = protocol.Stream; IsEncrypted = true; } catch (Exception ex) { Console.WriteLine("Fault opening TLS connection {0}", ex.Message); State = ChannelState.Aborted; Trace.TraceError(ex.Message); OnError?.Invoke(this, new ChannelErrorEventArgs(Id, ex)); return; } } else if (certificate != null) { stream = new SslStream(localStream, true, new RemoteCertificateValidationCallback(ValidateCertificate)); IsEncrypted = true; try { await((SslStream)stream).AuthenticateAsServerAsync(certificate, clientAuth, SslProtocols.Tls12, true); } catch (AggregateException ae) { State = ChannelState.Aborted; Trace.TraceError(ae.Flatten().Message); OnError?.Invoke(this, new ChannelErrorEventArgs(Id, ae)); throw; } catch (Exception ex) { State = ChannelState.Aborted; Trace.TraceError(ex.Message); OnError?.Invoke(this, new ChannelErrorEventArgs(Id, ex)); throw; } } else { stream = localStream; } State = ChannelState.Open; OnOpen?.Invoke(this, new ChannelOpenEventArgs(Id, null)); }
public ChannelButton(int channelNumber) { Click += Mute; ChannelState = new ChannelState(this, channelNumber); SetInstrument(null); SetContentAndColors(); }
internal DataChannel(PeerConnection peerConnection, int id, string label, bool ordered, bool reliable) { PeerConnection = peerConnection; ID = id; Label = label; Ordered = ordered; Reliable = reliable; State = ChannelState.Connecting; // see PeerConnection.AddDataChannelImpl() }
public override async Task SendAsync(byte[] message) { try { HttpWebRequest request = GetRequest(HttpMethod.Post); request.ContentLength = message.Length; Port = request.RequestUri.Port; IsEncrypted = request.RequestUri.Scheme == "https"; using (Stream stream = await request.GetRequestStreamAsync().WithCancellation(internalToken)) { await stream.WriteAsync(message, 0, message.Length); } using (HttpWebResponse response = await request.GetResponseAsync().WithCancellation(internalToken) as HttpWebResponse) { if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Accepted || response.StatusCode == HttpStatusCode.NoContent) { IsAuthenticated = true; State = ChannelState.CloseSent; } else { State = ChannelState.Aborted; OnError?.Invoke(this, new ChannelErrorEventArgs(Id, new WebException( String.Format("Invalid HTTP response status code {0}", response.StatusCode)))); } } } catch (OperationCanceledException oce) { Trace.TraceWarning("Http channel cancelled."); State = ChannelState.Aborted; OnError?.Invoke(this, new ChannelErrorEventArgs(Id, oce)); } catch (AggregateException ae) { State = ChannelState.Aborted; OnError?.Invoke(this, new ChannelErrorEventArgs(Id, ae.Flatten())); } catch (WebException we) { Trace.TraceError("Channel '{0}' error with '{1}'", Id, we.Message); State = ChannelState.Aborted; OnError?.Invoke(this, new ChannelErrorEventArgs(Id, we.InnerException)); } catch (Exception ex) { Trace.TraceError("Channel '{0}' error with '{1}'", Id, ex.Message); State = ChannelState.Aborted; OnError?.Invoke(this, new ChannelErrorEventArgs(Id, ex)); } }
/// <summary> /// Returned tasks completes once channel state has become different from /// given lastObservedState. /// If deadline is reached or and error occurs, returned task is cancelled. /// </summary> public async Task WaitForStateChangedAsync(ChannelState lastObservedState, DateTime?deadline = null) { var result = await TryWaitForStateChangedAsync(lastObservedState, deadline).ConfigureAwait(false); if (!result) { throw new TaskCanceledException("Reached deadline."); } }
public bool SetChannelState(string seed, ChannelState state) { lock (_lockObject) { var channel = _channels.SingleOrDefault(x => x.Seed == seed); channel?.SetState(state); return(true); } }
/// <summary> /// Remove the data track from the peer connection and destroy it. /// </summary> public void Dispose() { State = ChannelState.Closing; PeerConnection.RemoveDataChannel(_interopHandle); _interopHandle = IntPtr.Zero; State = ChannelState.Closed; _handle.Free(); GC.SuppressFinalize(this); }
public Task <bool> SetAllChannels(ChannelState channelState) { for (int i = 0; i < 64; i++) { this.InternalSetChannel(i + 1, channelState); } return(this.Push()); }
void Awake() { channelArray = new ChannelState[17]; for (var i = 0; i < 17; i++) { channelArray [i] = new ChannelState(); } }
private void Connect() { var rabbitHost = ConfigurationManager.AppSettings["RabbitMqHost"]; var rabbitUsername = ConfigurationManager.AppSettings["RabbitMqUsername"]; var rabbitPassword = ConfigurationManager.AppSettings["RabbitMqPassword"]; var factory = new ConnectionFactory { HostName = rabbitHost, UserName = rabbitUsername, Password = rabbitPassword, AutomaticRecoveryEnabled = true, RequestedHeartbeat = 30 }; Connection = factory.CreateConnection(); Connection.ConnectionShutdown += Connection_ConnectionShutdown; ChannelVariableList = Connection.CreateModel(); ChannelInfo = Connection.CreateModel(); ChannelState = Connection.CreateModel(); ChannelMessages = Connection.CreateModel(); ChannelTool = Connection.CreateModel(); ChannelHistoryJobPieceBar = Connection.CreateModel(); ChannelVariableList.QueueDeclare("VariableList", true, false, false, null); ChannelInfo.QueueDeclare("Info", true, false, false, null); ChannelState.QueueDeclare("State", true, false, false, null); ChannelMessages.QueueDeclare("Messages", true, false, false, null); ChannelTool.QueueDeclare("Tool", true, false, false, null); ChannelHistoryJobPieceBar.QueueDeclare("HistoryJobPieceBar", true, false, false, null); }
public void logConnectionStatus(String mrid, ChannelState state) { // find match if (getMRID().Equals(mrid)) { string tmps = "channel state: " + state + " for dev: " + myDev.Name + " addr: " + myDev.Dnp.IPAddress; th.updateState(tmps); chState = state; } }
internal SubChannel(PmlCommunicator communicator, UInt32 sid, bool accepted) { _communicator = communicator; _id = sid; _state = accepted ? ChannelState.Acknowledged : ChannelState.Requesting; if (accepted) { _communicator.AddSession(this); } }
/// <summary> /// /// </summary> /// <param name="context"></param> public override void ChannelActive(IChannelHandlerContext context) { ChannelState.SetLoginState(context, false); logger.LogDebug($"Channel actived. Local={context.GetLocalNetString()}, Remote={context.GetRemoteNetString()}"); channelHandlerContextManager.Regist(context); base.ChannelActive(context); }
void HandleException(Exception ex) { if (ex is RpcException) { if (_grpcChannel.State != ChannelState.Ready) { State = _grpcChannel.State; } } }
public KPort(KernelContext context, int maxSessions, bool isLight, long nameAddress) : base(context) { ServerPort = new KServerPort(context, this); ClientPort = new KClientPort(context, this, maxSessions); IsLight = isLight; _nameAddress = nameAddress; _state = ChannelState.Open; }
public MidiTrackState() { _channelStates = new ChannelState[kNumberOfChannels]; for (int i = 0; i < kNumberOfChannels; i++) { _channelStates[i] = new ChannelState(); } _source = eSource.AnyLiveSource; }
private static IWebSocket4NetTransportSyntax GetWebSocketSyntax(ChannelFactorySyntax.IRealmSyntax realmSyntax, WebSocket4NetActivator activator) { ChannelState state = realmSyntax.State; state.ConnectionActivator = activator; WebSocket4NetTransportSyntax syntax = new WebSocket4NetTransportSyntax(state); return(syntax); }
/// <summary> /// Dispose of the native data channel. Invoked by its owner (<see cref="PeerConnection"/>). /// </summary> internal void DestroyNative() { if (State != ChannelState.Closed) { _nativeHandle = IntPtr.Zero; State = ChannelState.Closed; Utils.ReleaseWrapperRef(_argsRef); _argsRef = IntPtr.Zero; } }
public KPort(Horizon system, int maxSessions, bool isLight, long nameAddress) : base(system) { ServerPort = new KServerPort(system, this); ClientPort = new KClientPort(system, this, maxSessions); IsLight = isLight; _nameAddress = nameAddress; _state = ChannelState.Open; }
public ChannelState CreateChannelState() { ChannelState chnl = new ChannelState(); chnl.ScrumEnabled = true; chnl.ScrumerIds = new List <ulong>(); chnl.UpdatedScrumerIds = new List <ulong>(); return(chnl); }
internal static Task WaitForState(this IRealtimeChannel channel, ChannelState awaitedState = ChannelState.Attached, TimeSpan?waitSpan = null) { var channelAwaiter = new ChannelAwaiter(channel, awaitedState); if (waitSpan.HasValue) { return(channelAwaiter.WaitAsync()); } return(channelAwaiter.WaitAsync()); }
public ChannelAwaiter(IRealtimeChannel channel, ChannelState awaitedState, ILogger logger = null, Action onTimeout = null) { Logger = logger ?? DefaultLogger.LoggerInstance; _name = $"#{channel.Name}:{awaitedState} awaiter"; _channel = channel as RealtimeChannel; _awaitedState = awaitedState; _timer = new CountdownTimer(_name + " timer", logger); _onTimeout = onTimeout; AttachListener(); }
/// <summary> /// Returned tasks completes once channel state has become different from /// given lastObservedState. /// If deadline is reached or and error occurs, returned task is cancelled. /// </summary> public Task WaitForStateChangedAsync(ChannelState lastObservedState, DateTime?deadline = null) { GrpcPreconditions.CheckArgument(lastObservedState != ChannelState.Shutdown, "Shutdown is a terminal state. No further state changes can occur."); var tcs = new TaskCompletionSource <object>(); var deadlineTimespec = deadline.HasValue ? Timespec.FromDateTime(deadline.Value) : Timespec.InfFuture; // pass "tcs" as "state" for WatchConnectivityStateHandler. handle.WatchConnectivityState(lastObservedState, deadlineTimespec, completionQueue, WatchConnectivityStateHandler, tcs); return(tcs.Task); }
protected AChannel(AService service, ChannelType channelType) { this.Id = IdGenerater.GenerateId(); this.ChannelType = channelType; this.m_Service = service; m_IsDisposed = false; m_ChannelState = ChannelState.EConnecting; this.m_LastRecvTime = service.TimeNow; this.m_CreateTime = service.TimeNow; }
/// <summary> /// Callback de notificação de desconexão do transporte. /// Notifica e depois finaliza todas as RPCs pendentes. /// </summary> /// <param name="sender">Instância geradora da notificação</param> /// <param name="reason">Motivo da desconexão</param> protected virtual void OnDisconnected(object sender, DisconnectReason reason) { m_State = ChannelState.Disconnected; foreach (var rpc in m_rpcs.Values.ToArray()) { rpc.OnDisconnected(GetSession(), reason); rpc.Dispose(); } m_rpcs.Clear(); }
/// <summary> /// Retorna o transporte para a conexão atual. /// Se ainda não estiver conectado, tenta conectar no servidor. /// O estado desconctado é um estado terminal. /// Retorna uma excessão caso não consiga conectar no servidor. /// </summary> /// <param name="forceConnect">Força uma reconexão mesmo que esteja desconectado.</param> /// <returns>O transporte atualmente conectado.</returns> protected IPacketTransport InternalGetTransport(bool forceConnect) { if (m_State == ChannelState.Connected) { return(m_transport); } lock (m_transportInitializeLock) { if (m_State == ChannelState.Connected) { return(m_transport); } if (!forceConnect) { if (m_State != ChannelState.NotConnected) { SocketException sex = new SocketException((int)SocketError.NotConnected); throw sex; } } m_State = ChannelState.Connecting; TcpClient client = new TcpClient(); IPacketTransport transport = null; try { client.Connect(m_remoteHostName, m_remotePort); // TODO: Channel: implement multiple transport options transport = new PacketTransport(client); transport.SetReceiveAction(OnPacketReceived); transport.SetDisconnectAction(OnDisconnected); transport.Start(); m_transport = transport; m_State = ChannelState.Connected; return(m_transport); } catch (Exception) { m_State = ChannelState.NotConnected; client?.Close(); transport?.Dispose(); throw; } } }
public MabiChannel(string name, string server, string ip, ushort port) { this.Name = name; this.ServerName = server; this.FullName = name + "@" + server; this.IP = ip; this.Port = port; this.State = ChannelState.Normal; this.Events = ChannelEvent.Normal; }
public Channel(string name, ChannelType type, IChannelListener listener) { this._id = Channel._nextId++; this._name = name + "-" + this.Id; this._state = ChannelState.STATE_HEADER; this._type = type; this._headerLength = 0; this._dataLength = 0; this._listener = listener; /* Force data state for AES key channel. */ if (this._type == ChannelType.TYPE_AESKEY) this._state = ChannelState.STATE_DATA; }
/// <summary> /// Sends Internal.ChannelStatus to login server with specified ChannelState. /// </summary> public static void Internal_ChannelStatus(ChannelState state) { var cur = ChannelServer.Instance.World.CountPlayers(); var max = ChannelServer.Instance.Conf.Channel.MaxUsers; var packet = new Packet(Op.Internal.ChannelStatus, 0); packet.PutString(ChannelServer.Instance.Conf.Channel.ChannelServer); packet.PutString(ChannelServer.Instance.Conf.Channel.ChannelName); packet.PutString(ChannelServer.Instance.Conf.Channel.ChannelHost); packet.PutInt(ChannelServer.Instance.Conf.Channel.ChannelPort); packet.PutInt(cur); packet.PutInt(max); packet.PutInt((int)state); ChannelServer.Instance.LoginServer.Send(packet); }
public Channel(string topic, JObject params_, Socket socket) { _state = ChannelState.Closed; Topic = topic; Socket = socket; _bindings = new Dictionary<string, List<Action<JObject, string>>>(); _alreadyJoinedOnce = false; _joinPush = new Push(this, ChannelEvents.Join, params_); _pushBuffer = new List<Push>(); _joinPush.Receive("ok", (x) => { _state = ChannelState.Joined; }); OnClose((o, reference) => { _state = ChannelState.Closed; Socket.Remove(this); }); OnError((reason, reference) => //reason is not used { _state = ChannelState.Errored; _rejoinTimer.Start(); }); On(ChannelEvents.Reply, (payload, reference) => { Trigger(ReplyEventName(reference), payload, reference); }); _rejoinTimer = new Timer(Socket.ReconnectAfterMs); _rejoinTimer.AutoReset = false; _rejoinTimer.Elapsed += (o, e) => RejoinUntilConnected(); //_rejoinTimer.Enabled = true; }
private static void UpdateChannelStateUsers(IList<IUser> allUsers, ChannelState chState, int channelId) { for (int i = 0; i < allUsers.Count; i++) { IUser u = null; try { u = allUsers[i]; } catch (NullReferenceException) {} if (u == null) continue; if (u.IsAdmin) continue; //scheduler users do not need to have their channelstates set. try { UpdateChannelStateUser(u, chState, channelId); } catch (NullReferenceException) {} } }
private void UpdateChannelStateUsers(IEnumerable<IUser> allUsers, ChannelState chState, int channelId) { foreach (IUser t in allUsers) { IUser u = null; try { u = t; } catch (NullReferenceException) {} if (u == null) continue; if (u.IsAdmin) continue; //scheduler users do not need to have their channelstates set. try { UpdateChannelStateUser(u, chState, channelId); } catch (NullReferenceException) {} } }
public Dram(Simulator sim, int channelBits, int bankBits) { Sim = sim; ChannelBits = channelBits; BankBits = bankBits; BankLsb = RowSizeBits + channelBits; RowLsb = BankLsb + bankBits; ClockDivider = 4; tCCD = 4; tCL = 11; tRCD = 11; tRP = 11; tRAS = 28; int numChannels = 1 << ChannelBits; int numBanksPerChannel = 1 << BankBits; Channels = new ChannelState[numChannels]; for (int i = 0; i < Channels.Length; i++) { Channels[i] = new ChannelState(numBanksPerChannel); } }
//sendJoin(timeout){ // this.state = CHANNEL_STATES.joining // this.joinPush.resend(timeout) //} private void SendJoin(int timeout) { _state = ChannelState.Joining; _joinPush.Resend(timeout); }
//constructor(topic, params, socket) { // this.state = CHANNEL_STATES.closed // this.topic = topic // this.params = params || {} // this.socket = socket // this.bindings = [] // this.timeout = this.socket.timeout // this.joinedOnce = false // this.joinPush = new Push(this, CHANNEL_EVENTS.join, this.params, this.timeout) // this.pushBuffer = [] // this.rejoinTimer = new Timer( // () => this.rejoinUntilConnected(), // this.socket.reconnectAfterMs // ) // this.joinPush.receive("ok", () => { // this.state = CHANNEL_STATES.joined // this.rejoinTimer.reset() // this.pushBuffer.forEach( pushEvent => pushEvent.send() ) // this.pushBuffer = [] // }) // this.onClose( () => { // this.socket.log("channel", `close ${this.topic}`) // this.state = CHANNEL_STATES.closed // this.socket.remove(this) // }) // this.onError( reason => { // this.socket.log("channel", `error ${this.topic}`, reason) // this.state = CHANNEL_STATES.errored // this.rejoinTimer.setTimeout() // }) // this.joinPush.receive("timeout", () => { // if(this.state !== CHANNEL_STATES.joining){ return } // this.socket.log("channel", `timeout ${this.topic}`, this.joinPush.timeout) // this.state = CHANNEL_STATES.errored // this.rejoinTimer.setTimeout() // }) // this.on(CHANNEL_EVENTS.reply, (payload, ref) => { // this.trigger(this.replyEventName(ref), payload) // }) //} public Channel(string topic, JObject params_, Socket socket) { _state = ChannelState.Closed; _topic = topic; _params = params_ ?? Phoenix.EMPTY_JS_OBJECT; _socket = socket; _bindings = new List<Binding>(); _timeout = _socket.Timeout; _joinedOnce = false; _joinPush = new Push(this, Phoenix.CHANNEL_EVENT_JOIN, _params, _timeout); _pushBuffer = new List<Push>(); _rejoinTimer = new RetryTimer(RejoinUntilConnected, _socket.ReconnectAfterMs); //jfis - why another timer instead of waiting for socket event? _joinPush.Receive("ok", (_) => { _socket.Log("JP REC OK", ""); _state = ChannelState.Joined; _rejoinTimer.Reset(); foreach (var p in _pushBuffer) p.Send(); _pushBuffer.Clear(); } ); OnClose(() => { _socket.Log("channel", $"close {_topic}"); _state = ChannelState.Closed; _socket.Remove(this); }); OnError( () => //reason only used for logging { _socket.Log("channel", $"error {_topic}"); //, reason); _state = ChannelState.Errored; _rejoinTimer.SetTimeout(); } ); _joinPush.Receive("timeout", (_) => { if (_state == ChannelState.Joining) return; _socket.Log("channel", $"timeout {_topic}");//, _joinPush.timeout) _state = ChannelState.Errored; _rejoinTimer.SetTimeout(); } ); On(Phoenix.CHANNEL_EVENT_REPLY, OnReply); }
/// <summary> /// Default constructor. /// </summary> /// <param name="oldState">Old channel state.</param> /// <param name="newState">New channel state.</param> public ChannelStateEventArgs(ChannelState oldState, ChannelState newState) { OldState = oldState; NewState = newState; }
public async Task<bool> Join() { lock(syncRoot) { if (joinTask == null) { oldState = state; state = ChannelState.Joining; joinTask = client.Self.JoinGroupChatAsync(group.ID); } } var result = await joinTask; lock(syncRoot) { state = result ? ChannelState.Connected : ChannelState.Failed; if(!result && oldState == ChannelState.Unconnected) { SendMessageDownstream(IntermediateMessage.ClientNotice(mapper.Client, "Could not join group " + SlName)); } } return result; }
/// <summary> /// Server has changed some detail of a channel /// </summary> /// <param name="channelState"></param> public virtual void ChannelState(ChannelState channelState) { var channel = ChannelDictionary.AddOrUpdate(channelState.channel_id, i => new Channel(this, channelState.channel_id, channelState.name, channelState.parent) { Temporary = channelState.temporary }, (i, c) => { c.Name = channelState.name; return c; } ); if (channel.Id == 0) RootChannel = channel; }
private Request BestRequest(ChannelState chan) { int best = -1; for (int i = 0; i < chan.WaitingReqs.Count; i++) { var req = chan.WaitingReqs[i]; if (chan.Banks[req.Bank].NextRequest > Sim.Now) { continue; } var state = ConflictState(req); if (state == RequestConflictState.Hit) { best = i; break; } if (best < 0) { if (state == RequestConflictState.Conflict && chan.Banks[req.Bank].NextConflict > Sim.Now) { continue; } best = i; } } if (best >= 0) { var req = chan.WaitingReqs[best]; chan.WaitingReqs.RemoveAt(best); return req; } return null; }
public void OnLocationUpdate(object sender, CoarseLocationUpdateEventArgs e) { var evt = new ChannelMemberChangeEventArgs(); Dictionary<UUID, ChannelMembership> nearbyAvatars; if (e.Simulator.Name != client.Network.CurrentSim.Name) return; if(!nearby.TryGetValue(e.Simulator.Name, out nearbyAvatars)) { nearbyAvatars = new Dictionary<UUID, ChannelMembership>(); nearby.Add(e.Simulator.Name, nearbyAvatars); } foreach(var i in e.NewEntries) { if (i == client.Self.AgentID) { continue; } var detail = new ChannelMemberChangeEventArgs.ChangeDetails(); detail.Subject = mapper.MapUser(i); detail.IsOperator = false; detail.WasOperator = false; detail.NewPosition = CategorisePosition(i, e); detail.OldPosition = PositionCategory.Distant; evt.NewMembers.Add(detail); var membership = new ChannelMembership(); membership.Subject = detail.Subject; membership.IsOperator = false; membership.Position = CategorisePosition(i, e); if (nearbyAvatars.ContainsKey(i)) { nearbyAvatars[i] = membership; } else { nearbyAvatars.Add(i, membership); } } foreach(var i in e.RemovedEntries) { if (i == client.Self.AgentID) { continue; } var detail = new ChannelMemberChangeEventArgs.ChangeDetails(); if (nearbyAvatars.ContainsKey(i)) { detail.Subject = nearbyAvatars[i].Subject; detail.IsOperator = false; detail.WasOperator = false; detail.NewPosition = PositionCategory.Distant; detail.OldPosition = nearbyAvatars[i].Position; evt.RemovedMembers.Add(detail); nearbyAvatars.Remove(i); } } foreach(var i in nearbyAvatars) { if (i.Key == client.Self.AgentID) { continue; } var newpos = CategorisePosition(i.Key, e); if (i.Value.Position != newpos) { var detail = new ChannelMemberChangeEventArgs.ChangeDetails(); detail.Subject = nearbyAvatars[i.Key].Subject; detail.IsOperator = false; detail.WasOperator = false; detail.NewPosition = newpos; detail.OldPosition = nearbyAvatars[i.Key].Position; evt.ChangedMembers.Add(detail); nearbyAvatars[i.Key].Position = newpos; } } if (!evt.HasChanges) { return; } lock (syncRoot) { if (state != ChannelState.Connected) { state = ChannelState.Connected; joinTask.SetResult(true); } } if(this.MembersChanged != null) { MembersChanged(this, evt); } }
void IPlatformInvocation.grpcsharp_channel_watch_connectivity_state(ChannelSafeHandle channel, ChannelState lastObservedState, Timespec deadline, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx) { grpcsharp_channel_watch_connectivity_state(channel, lastObservedState, deadline, cq, ctx); }
void Initialize() { if( channelArray == null ) { channelArray = new ChannelState[17]; for (var i = 0; i < 17; i++) { channelArray [i] = new ChannelState (); } } }
protected void SetChannelState(ChannelState state) { if (state == m_ChannelState) { return; } m_ChannelState = state; try { //if (ChannelStateChanged != null) //{ // this.ChannelStateChanged(state); //} } catch (Exception x) { ReportError(x.ToString()); } }
MidiDriver() { _channelArray = new ChannelState[17]; for (var i = 0; i < 17; i++) _channelArray[i] = new ChannelState(); #if UNITY_EDITOR _messageHistory = new Queue<MidiMessage>(); #endif }
public void Init() { State = ChannelState.Unjoined; }
void SetState(ChannelState newState) { ChannelState oldState = State; State = newState; if(ChannelStateChanged != null) ChannelStateChanged(oldState,newState); }
public static string StateToString(ChannelState state) { var stateStr = state.ToString(); var temp = "CS_" + char.ToUpper(stateStr[0]); for (var i = 1; i < stateStr.Length; i++) { if (char.IsUpper(stateStr[i])) temp += stateStr[i] + "_"; else temp += char.ToUpper(stateStr[i]); } return temp; }
/// <summary> /// Returned tasks completes once channel state has become different from /// given lastObservedState. /// If deadline is reached or and error occurs, returned task is cancelled. /// </summary> public Task WaitForStateChangedAsync(ChannelState lastObservedState, DateTime? deadline = null) { Preconditions.CheckArgument(lastObservedState != ChannelState.FatalFailure, "FatalFailure is a terminal state. No further state changes can occur."); var tcs = new TaskCompletionSource<object>(); var deadlineTimespec = deadline.HasValue ? Timespec.FromDateTime(deadline.Value) : Timespec.InfFuture; var handler = new BatchCompletionDelegate((success, ctx) => { if (success) { tcs.SetResult(null); } else { tcs.SetCanceled(); } }); handle.WatchConnectivityState(lastObservedState, deadlineTimespec, environment.CompletionQueue, environment.CompletionRegistry, handler); return tcs.Task; }
void Awake () { channelArray = new ChannelState[17]; for (var i = 0; i < 17; i++) { channelArray [i] = new ChannelState (); } #if UNITY_EDITOR messageHistory = new Queue<MidiMessage> (); #endif }
public Task<bool> Join() { lock(syncRoot) { if(state != ChannelState.Connected) state = ChannelState.Joining; } return joinTask.Task; }
static extern void grpcsharp_channel_watch_connectivity_state(ChannelSafeHandle channel, ChannelState lastObservedState, Timespec deadline, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx);
void Awake () { channelArray = new ChannelState[17]; for (var i = 0; i < 17; i++) { channelArray [i] = new ChannelState (); } }