internal override void RaiseDataReceivedEvent(RemoteDataEventArgs dataArg) { if (dataArg == null) { throw PSTraceSource.NewArgumentNullException("dataArg"); } RemoteDataObject<PSObject> receivedData = dataArg.ReceivedData; RemotingTargetInterface targetInterface = receivedData.TargetInterface; RemotingDataType dataType = receivedData.DataType; switch (dataType) { case RemotingDataType.SessionCapability: { RemoteSessionCapability remoteSessionCapability = null; try { remoteSessionCapability = RemotingDecoder.GetSessionCapability(receivedData.Data); } catch (PSRemotingDataStructureException exception2) { throw new PSRemotingDataStructureException(RemotingErrorIdStrings.ServerNotFoundCapabilityProperties, new object[] { exception2.Message, PSVersionInfo.BuildVersion, RemotingConstants.ProtocolVersion }); } RemoteSessionStateMachineEventArgs fsmEventArg = new RemoteSessionStateMachineEventArgs(RemoteSessionEvent.NegotiationReceived) { RemoteSessionCapability = remoteSessionCapability }; this._stateMachine.RaiseEvent(fsmEventArg); if (this.NegotiationReceived != null) { RemoteSessionNegotiationEventArgs eventArgs = new RemoteSessionNegotiationEventArgs(remoteSessionCapability) { RemoteData = receivedData }; this.NegotiationReceived.SafeInvoke<RemoteSessionNegotiationEventArgs>(this, eventArgs); } return; } case RemotingDataType.CloseSession: { PSRemotingDataStructureException reason = new PSRemotingDataStructureException(RemotingErrorIdStrings.ClientRequestedToCloseSession); RemoteSessionStateMachineEventArgs args = new RemoteSessionStateMachineEventArgs(RemoteSessionEvent.Close, reason); this._stateMachine.RaiseEvent(args); return; } case RemotingDataType.CreateRunspacePool: this.CreateRunspacePoolReceived.SafeInvoke<RemoteDataEventArgs>(this, dataArg); return; case RemotingDataType.PublicKey: { string publicKey = RemotingDecoder.GetPublicKey(receivedData.Data); this.PublicKeyReceived.SafeInvoke<RemoteDataEventArgs<string>>(this, new RemoteDataEventArgs<string>(publicKey)); return; } } throw new PSRemotingDataStructureException(RemotingErrorIdStrings.ReceivedUnsupportedAction, new object[] { dataType }); }
private void ProcessSessionMessages(RemoteDataEventArgs arg) { if ((arg == null) || (arg.ReceivedData == null)) { throw PSTraceSource.NewArgumentNullException("arg"); } RemoteDataObject<PSObject> receivedData = arg.ReceivedData; RemotingTargetInterface targetInterface = receivedData.TargetInterface; RemotingDataType dataType = receivedData.DataType; switch (dataType) { case RemotingDataType.SessionCapability: { RemoteSessionCapability remoteSessionCapability = null; try { remoteSessionCapability = RemotingDecoder.GetSessionCapability(receivedData.Data); } catch (PSRemotingDataStructureException exception2) { throw new PSRemotingDataStructureException(RemotingErrorIdStrings.ClientNotFoundCapabilityProperties, new object[] { exception2.Message, PSVersionInfo.BuildVersion, RemotingConstants.ProtocolVersion }); } RemoteSessionStateMachineEventArgs args2 = new RemoteSessionStateMachineEventArgs(RemoteSessionEvent.NegotiationReceived) { RemoteSessionCapability = remoteSessionCapability }; this._stateMachine.RaiseEvent(args2, false); RemoteSessionNegotiationEventArgs eventArgs = new RemoteSessionNegotiationEventArgs(remoteSessionCapability); this.NegotiationReceived.SafeInvoke<RemoteSessionNegotiationEventArgs>(this, eventArgs); return; } case RemotingDataType.CloseSession: { PSRemotingDataStructureException reason = new PSRemotingDataStructureException(RemotingErrorIdStrings.ServerRequestedToCloseSession); RemoteSessionStateMachineEventArgs args = new RemoteSessionStateMachineEventArgs(RemoteSessionEvent.Close, reason); this._stateMachine.RaiseEvent(args, false); return; } case RemotingDataType.EncryptedSessionKey: { string encryptedSessionKey = RemotingDecoder.GetEncryptedSessionKey(receivedData.Data); this.EncryptedSessionKeyReceived.SafeInvoke<RemoteDataEventArgs<string>>(this, new RemoteDataEventArgs<string>(encryptedSessionKey)); return; } case RemotingDataType.PublicKeyRequest: this.PublicKeyRequestReceived.SafeInvoke<RemoteDataEventArgs<string>>(this, new RemoteDataEventArgs<string>(string.Empty)); return; } throw new PSRemotingDataStructureException(RemotingErrorIdStrings.ReceivedUnsupportedAction, new object[] { dataType }); }
private void HandleNegotiationReceived(object sender, RemoteSessionNegotiationEventArgs arg) { using (_trace.TraceEventHandlers()) { if (arg == null) { throw PSTraceSource.NewArgumentNullException("arg"); } if (arg.RemoteSessionCapability == null) { throw PSTraceSource.NewArgumentException("arg"); } base.Context.ServerCapability = arg.RemoteSessionCapability; try { this.RunClientNegotiationAlgorithm(base.Context.ServerCapability); RemoteSessionStateMachineEventArgs args = new RemoteSessionStateMachineEventArgs(RemoteSessionEvent.NegotiationCompleted); base.SessionDataStructureHandler.StateMachine.RaiseEvent(args, false); } catch (PSRemotingDataStructureException exception) { RemoteSessionStateMachineEventArgs args2 = new RemoteSessionStateMachineEventArgs(RemoteSessionEvent.NegotiationFailed, exception); base.SessionDataStructureHandler.StateMachine.RaiseEvent(args2, false); } } }
private void HandleNegotiationReceived(object sender, RemoteSessionNegotiationEventArgs negotiationEventArg) { if (negotiationEventArg == null) { throw PSTraceSource.NewArgumentNullException("negotiationEventArg"); } try { this._context.ClientCapability = negotiationEventArg.RemoteSessionCapability; this.RunServerNegotiationAlgorithm(negotiationEventArg.RemoteSessionCapability, false); RemoteSessionStateMachineEventArgs fsmEventArg = new RemoteSessionStateMachineEventArgs(RemoteSessionEvent.NegotiationSending); this._sessionDSHandler.StateMachine.RaiseEvent(fsmEventArg); RemoteSessionStateMachineEventArgs args2 = new RemoteSessionStateMachineEventArgs(RemoteSessionEvent.NegotiationCompleted); this._sessionDSHandler.StateMachine.RaiseEvent(args2); } catch (PSRemotingDataStructureException exception) { RemoteSessionStateMachineEventArgs args3 = new RemoteSessionStateMachineEventArgs(RemoteSessionEvent.NegotiationSending); this._sessionDSHandler.StateMachine.RaiseEvent(args3); RemoteSessionStateMachineEventArgs args4 = new RemoteSessionStateMachineEventArgs(RemoteSessionEvent.NegotiationFailed, exception); this._sessionDSHandler.StateMachine.RaiseEvent(args4); } }