/// <summary> /// Invoked when an incoming request for Handshake operation comes in. /// </summary> public abstract void OnHandshake(IClient client, HandshakeRequest packet);
/// <summary> /// Occurs when a remote client attempts to handshake with a target within the application. /// </summary> /// <param name="client">The remote client.</param> /// <param name="packet">The packet received.</param> private static void OnHandshake(IClient client, HandshakeRequest packet) { try { // Get the parameters var callback = packet.Callback; var request = JsonConvert.DeserializeObject<Handshake>(packet.Value); if (request == null) return; // Attempt to fetch the app var app = AppServer.Current.GetByKey(request.Application); if (app == null) return; // We need to create a view scope, with the provided class type and the // view name is actually the prototype, as we only create one scope per // session, sharing it accross pages. Subject to change. Scope scope = app.Application.Scope .Within<SessionScope>(request.Session) .Within<PageScope>(request.View, request.View); // If we are attempting to create an element, we need to create an // element scope, with the provided class type and the name, inside // the appropriate view. if(request.Type == Handshake.HandshakeType.Element) { // Go deeper within scope tree scope = scope.Within<ElementScope>(request.Element, "E" + request.Instance); } // Reply with the target, only if we have a proper scope if(scope != null) client.SendHandshakeInform(callback, scope.Oid); } catch (Exception ex) { // Log the exception Service.Logger.Log(ex); } }