예제 #1
0
        /// <summary>
        /// Creates a new "pending session" and sends a connection request to the specified service.
        /// </summary>
        /// <param name="serviceId">The service identifier.</param>
        /// <returns>
        /// The new pending session id.
        /// </returns>
        /// <exception cref="KeyNotFoundException">The specified resonance service was not found.</exception>
        public virtual string Connect(string serviceId)
        {
            Validate(_getConnectionId());

            var service = Repository.GetService(serviceId);

            if (service == null)
            {
                throw new KeyNotFoundException("The specified resonance service was not found.");
            }

            var newPendingSession = new ResonanceHubSession <TServiceInformation>()
            {
                ConnectedConnectionId = _getConnectionId(),
                Service = service,
            };

            Repository.AddSession(newPendingSession);

            TAdapterInformation adapterInformation = GetAdapterInformation(_getConnectionId());

            _invoke(ResonanceHubMethods.ConnectionRequest, service.ConnectionId, newPendingSession.SessionId, adapterInformation);

            return(newPendingSession.SessionId);
        }
 /// <summary>
 /// Adds the specified session.
 /// </summary>
 /// <param name="session">The session.</param>
 public void AddSession(ResonanceHubSession <TServiceInformation> session)
 {
     _sessions.Add(session);
 }
 /// <summary>
 /// Removes the specified session.
 /// </summary>
 /// <param name="session">The session.</param>
 public void RemoveSession(ResonanceHubSession <TServiceInformation> session)
 {
     _sessions.Remove(session);
 }