コード例 #1
0
        public void OnCreateAndJoinRoomAnswer(ProtobufPacket <CreateAndJoinRoomAnswerPacket> packet)
        {
            CreateAndJoinRoomAnswerPacket answer = packet.ProtobufMessage;

            OnCreateRoom?.Invoke(this, answer.Success);
            OnJoinRoom?.Invoke(this, new Tuple <string, bool>(answer.RoomName, answer.Success));
        }
コード例 #2
0
        public void OnCreateRoomAnswer(ProtobufPacket <CreateRoomAnswerPacket> packet)
        {
            CreateRoomAnswerPacket answer = packet.ProtobufMessage;

            if (answer.Success == true)
            {
                Debug.Log("방 생성 성공");
            }
            else
            {
                Debug.Log("방 생성 실패");
            }

            OnCreateRoom?.Invoke(this, answer.Success);
        }
コード例 #3
0
ファイル: LineClient.cs プロジェクト: zhushengwen/LineSharp
        //This is where update code goes, aka dispatching delegates
        public void Update()
        {
            Operation operation = GetNextOperation();

            if (operation == null)
            {
                return;
            }

#if DEBUG
            Console.WriteLine("Operation recieved.");
            Console.WriteLine(">>Type: " + operation.Type);
            Console.WriteLine(">>Oprev: " + operation.Revision);
            Console.WriteLine(">>Param1: " + operation.Param1);
            Console.WriteLine(">>Param2: " + operation.Param2);
            Console.WriteLine(">>Param3: " + operation.Param3);
            if (operation.Message != null)
            {
                Console.WriteLine(">>Message: ");
                Console.WriteLine(">>>Text: " + operation.Message.Text);
                if (operation.Message.ContentMetadata != null)
                {
                    Console.WriteLine(">>>Content-Metadata:");
                    foreach (KeyValuePair <string, string> kvp in operation.Message.ContentMetadata)
                    {
                        Console.WriteLine(">>>>Key = {0}, Value = {1}",
                                          kvp.Key, kvp.Value);
                    }
                }
                Console.WriteLine(">>>>CreatedTime: " + operation.Message.CreatedTime);
                Console.WriteLine(">>>>DeliveredTime: " + operation.Message.DeliveredTime);
                Console.WriteLine(">>>ID: " + operation.Message.Id);
                Console.WriteLine(">>>To: " + operation.Message.To);
                Console.WriteLine(">>>From: " + operation.Message.From);
                Console.WriteLine(">>>Type: " + operation.Message.ContentType);
            }



            Console.WriteLine();
#endif

            switch (operation.Type)
            {
            case OpType.END_OF_OPERATION:
                //if (OnEndofOperation != null) OnEndofOperation.Invoke(this, new EndofOperationEventArgs());
                break;

            case OpType.UPDATE_PROFILE:
                if (OnUpdateProfile != null)
                {
                    OnUpdateProfile.Invoke(this, new UpdateProfileEventArgs());
                }
                break;

            case OpType.NOTIFIED_UPDATE_PROFILE:
                if (OnNotifiedUpdateProfile != null)
                {
                    OnNotifiedUpdateProfile.Invoke(this, new NotifiedUpdateProfileEventArgs(operation.Param1));
                }
                break;

            case OpType.REGISTER_USERID:
                if (OnRegisterUserid != null)
                {
                    OnRegisterUserid.Invoke(this, new RegisterUseridEventArgs());
                }
                break;

            case OpType.ADD_CONTACT:
                if (OnAddContact != null)
                {
                    OnAddContact.Invoke(this, new UserMidArgs(operation.Param1));
                }
                break;

            case OpType.NOTIFIED_ADD_CONTACT:
                if (OnNotifiedAddContact != null)
                {
                    OnNotifiedAddContact.Invoke(this, new UserMidArgs(operation.Param1));
                }
                break;

            case OpType.BLOCK_CONTACT:
                if (OnBlockContact != null)
                {
                    OnBlockContact.Invoke(this, new UserMidArgs(operation.Param1));
                }
                break;

            case OpType.UNBLOCK_CONTACT:
                if (OnUnblockContact != null)
                {
                    OnUnblockContact.Invoke(this, new UserMidArgs(operation.Param1));
                }
                break;

            case OpType.NOTIFIED_RECOMMEND_CONTACT:
                if (OnNotifiedRecommendContact != null)
                {
                    OnNotifiedRecommendContact.Invoke(this, new NotifiedRecommendContactEventArgs());
                }
                break;

            case OpType.CREATE_GROUP:
                if (OnCreateGroup != null)
                {
                    OnCreateGroup.Invoke(this, new CreateGroupEventArgs());
                }
                break;

            case OpType.UPDATE_GROUP:
                if (OnUpdateGroup != null)
                {
                    OnUpdateGroup.Invoke(this, new UserMidArgs(operation.Param1));
                }
                break;

            case OpType.NOTIFIED_UPDATE_GROUP:
                if (OnNotifiedUpdateGroup != null)
                {
                    OnNotifiedUpdateGroup.Invoke(this, new ItemUserMidArgs(operation.Param1, operation.Param2));
                }
                break;

            case OpType.INVITE_INTO_GROUP:
                if (OnInviteintoGroup != null)
                {
                    OnInviteintoGroup.Invoke(this, new InviteintoGroupEventArgs(operation.Param1, operation.Param2));
                }
                break;

            case OpType.NOTIFIED_INVITE_INTO_GROUP:
                if (OnNotifiedInviteintoGroup != null)
                {
                    OnNotifiedInviteintoGroup.Invoke(this, new NotifiedInviteintoGroupEventArgs());
                }
                break;

            case OpType.LEAVE_GROUP:
                if (OnLeaveGroup != null)
                {
                    OnLeaveGroup.Invoke(this, new LeaveGroupEventArgs());
                }
                break;

            case OpType.NOTIFIED_LEAVE_GROUP:
                if (OnNotifiedLeaveGroup != null)
                {
                    OnNotifiedLeaveGroup.Invoke(this, new NotifiedLeaveGroupEventArgs());
                }
                break;

            case OpType.ACCEPT_GROUP_INVITATION:
                if (OnAcceptGroupInvitation != null)
                {
                    OnAcceptGroupInvitation.Invoke(this, new AcceptGroupInvitationEventArgs());
                }
                break;

            case OpType.NOTIFIED_ACCEPT_GROUP_INVITATION:
                if (OnNotifiedAcceptGroupInvitation != null)
                {
                    OnNotifiedAcceptGroupInvitation.Invoke(this, new NotifiedAcceptGroupInvitationEventArgs());
                }
                break;

            case OpType.KICKOUT_FROM_GROUP:
                if (OnKickoutfromGroup != null)
                {
                    OnKickoutfromGroup.Invoke(this, new KickoutfromGroupEventArgs());
                }
                break;

            case OpType.NOTIFIED_KICKOUT_FROM_GROUP:
                if (OnNotifiedKickoutfromGroup != null)
                {
                    OnNotifiedKickoutfromGroup.Invoke(this, new NotifiedKickoutfromGroupEventArgs());
                }
                break;

            case OpType.CREATE_ROOM:
                if (OnCreateRoom != null)
                {
                    OnCreateRoom.Invoke(this, new CreateRoomEventArgs());
                }
                break;

            case OpType.INVITE_INTO_ROOM:
                if (OnInviteintoRoom != null)
                {
                    OnInviteintoRoom.Invoke(this, new InviteintoRoomEventArgs());
                }
                break;

            case OpType.NOTIFIED_INVITE_INTO_ROOM:
                if (OnNotifiedInviteintoRoom != null)
                {
                    OnNotifiedInviteintoRoom.Invoke(this, new NotifiedInviteintoRoomEventArgs());
                }
                break;

            case OpType.LEAVE_ROOM:
                if (OnLeaveRoom != null)
                {
                    OnLeaveRoom.Invoke(this, new LeaveRoomEventArgs());
                }
                break;

            case OpType.NOTIFIED_LEAVE_ROOM:
                if (OnNotifiedLeaveRoom != null)
                {
                    OnNotifiedLeaveRoom.Invoke(this, new NotifiedLeaveRoomEventArgs());
                }
                break;

            case OpType.SEND_MESSAGE:
                if (OnSendMessage != null)
                {
                    OnSendMessage.Invoke(this, new SendMessageEventArgs());
                }
                break;

            case OpType.RECEIVE_MESSAGE:
                if (OnReceiveMessage != null)
                {
                    OnReceiveMessage.Invoke(this, new ReceiveMessageEventArgs(operation.Message));
                }
                break;

            case OpType.SEND_MESSAGE_RECEIPT:
                if (OnSendMessageReceipt != null)
                {
                    OnSendMessageReceipt.Invoke(this, new SendMessageReceiptEventArgs());
                }
                break;

            case OpType.RECEIVE_MESSAGE_RECEIPT:
                if (OnReceiveMessageReceipt != null)
                {
                    OnReceiveMessageReceipt.Invoke(this, new ReceiveMessageReceiptEventArgs());
                }
                break;

            case OpType.SEND_CONTENT_RECEIPT:
                if (OnSendContentReceipt != null)
                {
                    OnSendContentReceipt.Invoke(this, new SendContentReceiptEventArgs());
                }
                break;

            case OpType.RECEIVE_ANNOUNCEMENT:
                if (OnReceiveAnnouncement != null)
                {
                    OnReceiveAnnouncement.Invoke(this, new ReceiveAnnouncementEventArgs());
                }
                break;

            case OpType.CANCEL_INVITATION_GROUP:
                if (OnCancelInvitationGroup != null)
                {
                    OnCancelInvitationGroup.Invoke(this, new CancelInvitationGroupEventArgs());
                }
                break;

            case OpType.NOTIFIED_CANCEL_INVITATION_GROUP:
                if (OnNotifiedCancelInvitationGroup != null)
                {
                    OnNotifiedCancelInvitationGroup.Invoke(this, new NotifiedCancelInvitationGroupEventArgs());
                }
                break;

            case OpType.NOTIFIED_UNREGISTER_USER:
                if (OnNotifiedUnregisterUser != null)
                {
                    OnNotifiedUnregisterUser.Invoke(this, new NotifiedUnregisterUserEventArgs());
                }
                break;

            case OpType.REJECT_GROUP_INVITATION:
                if (OnRejectGroupInvitation != null)
                {
                    OnRejectGroupInvitation.Invoke(this, new RejectGroupInvitationEventArgs());
                }
                break;

            case OpType.NOTIFIED_REJECT_GROUP_INVITATION:
                if (OnNotifiedRejectGroupInvitation != null)
                {
                    OnNotifiedRejectGroupInvitation.Invoke(this, new NotifiedRejectGroupInvitationEventArgs());
                }
                break;

            case OpType.UPDATE_SETTINGS:
                if (OnUpdateSettings != null)
                {
                    OnUpdateSettings.Invoke(this, new UpdateSettingsEventArgs());
                }
                break;

            case OpType.NOTIFIED_REGISTER_USER:
                if (OnNotifiedRegisterUser != null)
                {
                    OnNotifiedRegisterUser.Invoke(this, new NotifiedRegisterUserEventArgs());
                }
                break;

            case OpType.INVITE_VIA_EMAIL:
                if (OnInviteviaEmail != null)
                {
                    OnInviteviaEmail.Invoke(this, new InviteviaEmailEventArgs());
                }
                break;

            case OpType.NOTIFIED_REQUEST_RECOVERY:
                if (OnNotifiedRequestRecovery != null)
                {
                    OnNotifiedRequestRecovery.Invoke(this, new NotifiedRequestRecoveryEventArgs());
                }
                break;

            case OpType.SEND_CHAT_CHECKED:
                if (OnSendChatChecked != null)
                {
                    OnSendChatChecked.Invoke(this, new SendChatCheckedEventArgs());
                }
                break;

            case OpType.SEND_CHAT_REMOVED:
                if (OnSendChatRemoved != null)
                {
                    OnSendChatRemoved.Invoke(this, new SendChatRemovedEventArgs());
                }
                break;

            case OpType.NOTIFIED_FORCE_SYNC:
                if (OnNotifiedForceSync != null)
                {
                    OnNotifiedForceSync.Invoke(this, new NotifiedForceSyncEventArgs());
                }
                break;

            case OpType.SEND_CONTENT:
                if (OnSendContent != null)
                {
                    OnSendContent.Invoke(this, new SendContentEventArgs());
                }
                break;

            case OpType.SEND_MESSAGE_MYHOME:
                if (OnSendMessageMyhome != null)
                {
                    OnSendMessageMyhome.Invoke(this, new SendMessageMyhomeEventArgs());
                }
                break;

            case OpType.NOTIFIED_UPDATE_CONTENT_PREVIEW:
                if (OnNotifiedUpdateContentPreview != null)
                {
                    OnNotifiedUpdateContentPreview.Invoke(this, new NotifiedUpdateContentPreviewEventArgs());
                }
                break;

            case OpType.REMOVE_ALL_MESSAGES:
                if (OnRemoveAllMessages != null)
                {
                    OnRemoveAllMessages.Invoke(this, new RemoveAllMessagesEventArgs());
                }
                break;

            case OpType.NOTIFIED_UPDATE_PURCHASES:
                if (OnNotifiedUpdatePurchases != null)
                {
                    OnNotifiedUpdatePurchases.Invoke(this, new NotifiedUpdatePurchasesEventArgs());
                }
                break;

            case OpType.DUMMY:
                if (OnDummy != null)
                {
                    OnDummy.Invoke(this, new DummyEventArgs());
                }
                break;

            case OpType.UPDATE_CONTACT:
                if (OnUpdateContact != null)
                {
                    OnUpdateContact.Invoke(this, new UpdateContactEventArgs());
                }
                break;

            case OpType.NOTIFIED_RECEIVED_CALL:
                if (OnNotifiedReceivedCall != null)
                {
                    OnNotifiedReceivedCall.Invoke(this, new NotifiedReceivedCallEventArgs());
                }
                break;

            case OpType.CANCEL_CALL:
                if (OnCancelCall != null)
                {
                    OnCancelCall.Invoke(this, new CancelCallEventArgs());
                }
                break;

            case OpType.NOTIFIED_REDIRECT:
                if (OnNotifiedRedirect != null)
                {
                    OnNotifiedRedirect.Invoke(this, new NotifiedRedirectEventArgs());
                }
                break;

            case OpType.NOTIFIED_CHANNEL_SYNC:
                if (OnNotifiedChannelSync != null)
                {
                    OnNotifiedChannelSync.Invoke(this, new NotifiedChannelSyncEventArgs());
                }
                break;

            case OpType.FAILED_SEND_MESSAGE:
                if (OnFailedSendMessage != null)
                {
                    OnFailedSendMessage.Invoke(this, new FailedSendMessageEventArgs());
                }
                break;

            case OpType.NOTIFIED_READ_MESSAGE:
                if (OnNotifiedReadMessage != null)
                {
                    OnNotifiedReadMessage.Invoke(this, new NotifiedReadMessageEventArgs());
                }
                break;

            case OpType.FAILED_EMAIL_CONFIRMATION:
                if (OnFailedEmailConfirmation != null)
                {
                    OnFailedEmailConfirmation.Invoke(this, new FailedEmailConfirmationEventArgs());
                }
                break;

            case OpType.NOTIFIED_CHAT_CONTENT:
                if (OnNotifiedChatContent != null)
                {
                    OnNotifiedChatContent.Invoke(this, new NotifiedChatContentEventArgs());
                }
                break;

            case OpType.NOTIFIED_PUSH_NOTICENTER_ITEM:
                if (OnNotifiedPushNoticenterItem != null)
                {
                    OnNotifiedPushNoticenterItem.Invoke(this, new NotifiedPushNoticenterItemEventArgs());
                }
                break;

            default:
                break;
            }
        }
コード例 #4
0
        private void XmppOnOnMessage(object sender, Message msg)
        {
            switch (msg.Type)
            {
            case MessageType.normal:
                if (msg.From.Server == "conference." + Skylabs.Lobby.Client.Host)
                {
                    var        rname = msg.From.User;
                    MucManager m     = new MucManager(_xmpp);
                    m.JoinRoom(msg.From, msg.From.User);
                    var theRoom = GetRoom(new NewUser(msg.From), true);
                    _xmpp.RosterManager.AddRosterItem(msg.From, msg.From.User);
                    if (OnCreateRoom != null)
                    {
                        OnCreateRoom.Invoke(this, theRoom);
                    }
                }
                break;

            case MessageType.error:
            {
                var nc = GetRoom(new NewUser(msg.From.Bare), true);
                nc.OnMessage(this, msg);
                break;
            }

            case MessageType.chat:
            {
                switch (msg.Chatstate)
                {
                case Chatstate.None:
                    //TODO Group chat whispers in the form of {roomname}@conference.server.octgn.info/{username} need to be handled here.
                    var nc = GetRoom(new NewUser(msg.From.Bare));
                    nc.OnMessage(sender, msg);
                    break;

                case Chatstate.active:

                    break;

                case Chatstate.inactive:
                    break;

                case Chatstate.composing:
                    break;

                case Chatstate.gone:
                    break;

                case Chatstate.paused:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;
            }

            case MessageType.groupchat:
            {
                var nc = GetRoom(new NewUser(msg.From.Bare), true);
                nc.OnMessage(this, msg);
                break;
            }

            case MessageType.headline:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }