some new methods
This commit is contained in:
+1
-1
@@ -38,7 +38,7 @@ namespace Interact
|
|||||||
//登录结果处理事件
|
//登录结果处理事件
|
||||||
public static event LoginDoneHandler OnLoginDone;
|
public static event LoginDoneHandler OnLoginDone;
|
||||||
//获取用户列表结果处理事件
|
//获取用户列表结果处理事件
|
||||||
private static event GetUserListDoneHandler OnGetUserListDone;
|
public static event GetUserListDoneHandler OnGetUserListDone;
|
||||||
|
|
||||||
//当前连接状态
|
//当前连接状态
|
||||||
public static ClientStatus Status
|
public static ClientStatus Status
|
||||||
|
|||||||
+24
-11
@@ -12,8 +12,16 @@ namespace StormChatWPF
|
|||||||
class Chat
|
class Chat
|
||||||
{
|
{
|
||||||
public static List<User> userlist = new List<User>();//联系人集合
|
public static List<User> userlist = new List<User>();//联系人集合
|
||||||
|
public static Chat chat = new Chat();
|
||||||
|
private Chat()
|
||||||
|
{
|
||||||
|
StormClient.OnLoginDone += HaveLogin;
|
||||||
|
StormClient.OnGetUserListDone += GetUserList;
|
||||||
|
StormClient.OnMessage +=ReciveMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
internal static void GetUsers(ResultHandler head, User user)
|
internal static void GetUsers(ResultHandler head, User user)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -27,13 +35,6 @@ namespace StormChatWPF
|
|||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
}//获取用户列表
|
}//获取用户列表
|
||||||
internal static void GetUserPhoto(ResultHead head, Image image)
|
|
||||||
{
|
|
||||||
if (head.Error != "")
|
|
||||||
{
|
|
||||||
MessageBox.Show("无法读取用户图片");
|
|
||||||
}
|
|
||||||
}//对用户头像进行赋值
|
|
||||||
internal void Log(string user,string password)
|
internal void Log(string user,string password)
|
||||||
{
|
{
|
||||||
if (StormClient.Initialize())
|
if (StormClient.Initialize())
|
||||||
@@ -55,7 +56,7 @@ namespace StormChatWPF
|
|||||||
User.Me = user;
|
User.Me = user;
|
||||||
MainWindow userWindow = new MainWindow();
|
MainWindow userWindow = new MainWindow();
|
||||||
userWindow.Show();
|
userWindow.Show();
|
||||||
LogWindow.a.Close();
|
LogWindow.Instence.Close();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -63,7 +64,19 @@ namespace StormChatWPF
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}//登录完成
|
}//登录完成
|
||||||
|
internal static void ReciveMessage(Message message)
|
||||||
|
{
|
||||||
|
LogWindow.Instence.ShowMessage(message);
|
||||||
|
}//接受到新消息的时候
|
||||||
|
internal static void SendMessage(string text,User target)
|
||||||
|
{
|
||||||
|
Message msg = new Message(text);
|
||||||
|
Action<BaseHead> f = delegate(BaseHead head)
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
StormClient.QueueSendMessage(msg, target, f);
|
||||||
|
LogWindow.Instence.ShowUserMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,20 +21,22 @@ namespace StormChatWPF
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class LogWindow : Window
|
public partial class LogWindow : Window
|
||||||
{
|
{
|
||||||
public static LogWindow a;
|
public static LogWindow Instence;
|
||||||
public LogWindow()
|
public LogWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
StormClient.OnLoginDone += Chat.HaveLogin;
|
Instence = this;
|
||||||
StormClient.OnGetUserListDone += Chat.GetUserList;
|
|
||||||
StormClient.OnGetUserPhotoDone += Chat.GetUserPhoto;
|
|
||||||
a = this;
|
|
||||||
}
|
}
|
||||||
Chat chat = new Chat();
|
|
||||||
private void Login_button_Click(object sender, RoutedEventArgs e)
|
private void Login_button_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
chat.Log(AccountBox.Text,passwordBox.Password);
|
Chat.chat.Log(AccountBox.Text,passwordBox.Password);
|
||||||
}
|
}
|
||||||
|
internal void ShowMessage(Message message)
|
||||||
|
{
|
||||||
|
|
||||||
|
}//将收到的消息展现于UI界面
|
||||||
|
internal void ShowUserMessage()
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user