Exemple #1
0
        IActivityHandler StartActivity(Guid activityId, IDictionary <string, object> args, string title = null)
        {
            IActivityExecutor executor = chatSession.CreateActivity(activityId);
            IActivity         activity = context.PluginLoader.GetActivity(activityId);
            IActivityHandler  handler  = activity.Coalesce(a => a.CreateInvite(executor, args));

            if (handler == null)
            {
                return(null);
            }

            if (handler is IVoiceChatHandler)
            {
                var voiceHandler = (IVoiceChatHandler)handler;
                voiceHandler.Dispatcher = Dispatcher;
                chatTextBox.AddVoiceChatSentRequest(context, voiceHandler, PrimaryBuddy.DisplayName);
            }
            else if (handler is IFileTransferHandler)
            {
                var fileHandler = (IFileTransferHandler)handler;
                fileTransfers.Add(fileHandler);
                chatTextBox.AddFileSentRequest(fileHandler);
            }
            else
            {
                chatTextBox.AddActivitySentRequest(PrimaryBuddy.DisplayName, title, handler);
            }

            handler.Start();
            chatState.ChatStarted = true;

            return(handler);
        }
Exemple #2
0
        void OnActivityInvite(ActivityInvitationReceivedEventArgs e)
        {
            IActivity        activity = context.PluginLoader.GetActivity(e.ActivityId);
            IActivityHandler handler  = activity.Coalesce(a => a.FromInvite(e.Executor, e.Metadata));

            if (e.ActivityId == SquiggleActivities.VoiceChat)
            {
                OnVoiceInvite(handler as IVoiceChatHandler);
            }
            else if (e.ActivityId == SquiggleActivities.FileTransfer)
            {
                OnTransferInvite(handler as IFileTransferHandler);
            }
            else
            {
                OnUnknownActivityInvite(activity.Coalesce(a => a.Title), handler);
            }
        }