⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ichat.cs

📁 Gibphone is CSharp Program, it can tell you how to design p2p chat.
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using GPCore.Args;

namespace GPCore.Protocols
{
    /// <summary>
    /// An interface to extend IProtocol if it supports chatrooms in addition to regular IMs.
    /// </summary>
    public interface IChat : IMessage
    {
        /// <summary>
        /// Call this to send a message to a certain chat.
        /// </summary>
        /// <param name="chatID">A unique chat ID for this chat.</param>
        /// <param name="msg">The message to send</param>
        /// <remarks>
        /// The ChatID only has to be unique enough for both the Protocol and other plugins to understand,
        /// therefore you dont have to worry about it conflicting with other chatID from other Protocols because
        /// a chat message will always relate to one IProtocol in specific so the combination of those two factors
        /// can make it unique with relative certainty.
        /// </remarks>
        void SendChat(int chatID, string msg);
        /// <summary>
        /// Called to create a new chat.
        /// </summary>
        /// <param name="name">The name of the new chatroom.</param>
        /// <returns>The unique ID of this new chatroom.</returns>
        [GPArgumentMethod("Open chat",typeof(User),"Chatroom Name",typeof(string))]
        int CreateChat(string name);
        /// <summary>
        /// Joins an already created chat, usually after an invite event was thrown.
        /// </summary>
        /// <param name="chatID">the unique ID of the chat to join.</param>
        /// <remarks>Remember this unique ID is only for use inside Gibphone, and therefore calling this function is not guaranted to
        /// join a chat and therefore it could result in you trying to join a chat that does not exist and maybe throw an exception 
        /// because of that.  If you want to join a chat that you know about from an outside source, i.e. an IRC room use the
        /// <see cref="CreateChat"/> function.</remarks>
        void JoinChat(int chatID);
        /// <summary>
        /// Invites a new person into the given chat.
        /// </summary>
        /// <param name="chatID">The unique ID of the chat.</param>
        /// <param name="username">The username of the person to invite.</param>
        /// <param name="message">An invitation message to send to contact.</param>
        void InvitePerson(int chatID, string username, string message);
        /// <summary>
        /// Invites a new person into a given chat.
        /// </summary>
        /// <param name="act">The account of the person you wish to invite.</param>
        /// <param name="name">The name of the chat you wish to invite the person into.</param>
        /// <param name="message">An invitation message to send to contact.</param>
        [GPArgumentMethod("Invite Person",typeof(SqlAccount),"Chat Room Name",typeof(string),"Message",typeof(string))]
        void InvitePerson(SqlAccount act, string name, string message);
        /// <summary>
        /// An Event thrown when a ChatMessage is Received.
        /// The EventArgs for this event are ChatArgs.
        /// The name for this event is onChatReceived.
        /// </summary>
        //event NotifyCore onChatReceived;
        /// <summary>
        /// An Event thrown when someone joins the chat.
        /// The EventArgs for this event are ChatUsernameArgs
        /// The namefor this event is onBuddyJoin
        /// </summary>
        //event NotifyCore onBuddyJoin;
        /// <summary>
        /// An Event thrown when someone leaves the chat.
        /// The EventArgs for this event are ChatUsernameArgs
        /// The namefor this event is onBuddyLeave
        /// </summary>
        //event NotifyCore onBuddyLeave;
        /// <summary>
        /// An Event thrown when the user creates a chatroom.
        /// The EventArgs for this event are NewChatArgs.
        /// The namefor this event is onChatCreated.
        /// </summary>
        //event NotifyCore onChatCreated;
        /// <summary>
        /// An Event thrown when someone invites the user to a chat.
        /// The EventArgs for this event are ChatInviteArgs
        /// The namefor this event is onChatInvite.
        /// </summary>
        /// <remarks>
        /// 
        /// </remarks>
        //event NotifyCore onChatInvite;
    }
    public static class Chat
    {
        public static Event<IChat, ChatArgs> ChatRecieved = new Event<IChat, ChatArgs>("ChatRecieved");
        public static Event<IChat, ChatUsernameArgs> BuddyJoin = new Event<IChat, ChatUsernameArgs>("BuddyJoined");
        public static Event<IChat, ChatUsernameArgs> BuddyLeft = new Event<IChat, ChatUsernameArgs>("BuddyLeft");
        public static Event<IChat, NewChatArgs> ChatCreated = new Event<IChat, NewChatArgs>("ChatCreated");
        public static Event<IChat, ChatInviteArgs> Invited = new Event<IChat, ChatInviteArgs>("Invited");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -