commonly commit
This commit is contained in:
@@ -20,5 +20,6 @@ namespace Interact
|
|||||||
public const string NickName = "NickName";
|
public const string NickName = "NickName";
|
||||||
public const string Motto = "Motto";
|
public const string Motto = "Motto";
|
||||||
public const string UGroup = "UGroup";
|
public const string UGroup = "UGroup";
|
||||||
|
public const string Photo = "Photo";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-9
@@ -4,6 +4,8 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
//StormClient对数据的处理相关内容
|
//StormClient对数据的处理相关内容
|
||||||
|
|
||||||
@@ -33,7 +35,7 @@ namespace Interact
|
|||||||
switch (jsonObj[AttrNames.Operation].ToString())
|
switch (jsonObj[AttrNames.Operation].ToString())
|
||||||
{
|
{
|
||||||
case Operations.Login:
|
case Operations.Login:
|
||||||
HandleLoginResult(GetResultHead(jsonObj), data);
|
HandleLoginResult(jsonObj, data);
|
||||||
break;
|
break;
|
||||||
case Operations.Panic:
|
case Operations.Panic:
|
||||||
HandlePanic(GetResultHead(jsonObj));
|
HandlePanic(GetResultHead(jsonObj));
|
||||||
@@ -68,23 +70,31 @@ namespace Interact
|
|||||||
}
|
}
|
||||||
|
|
||||||
//处理登录反馈消息
|
//处理登录反馈消息
|
||||||
private static void HandleLoginResult(ResultHead head, byte[] data)
|
private static void HandleLoginResult(JObject head, byte[] data)
|
||||||
{
|
{
|
||||||
|
//提取结果包头
|
||||||
|
ResultHead resultHead = GetResultHead(head);
|
||||||
//发起登录完成事件
|
//发起登录完成事件
|
||||||
if (head.Error != "")
|
if (head[AttrNames.Error].ToString() != "")
|
||||||
{
|
{
|
||||||
OnLoginDone?.Invoke(head, null);
|
OnLoginDone?.Invoke(resultHead, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JObject dataObj = (JObject)JsonConvert.DeserializeObject(Encoding.UTF8.GetString(data));
|
JObject dataObj = (JObject)JsonConvert.DeserializeObject(Encoding.UTF8.GetString(data));
|
||||||
User user = new User
|
User user = new User
|
||||||
{
|
{
|
||||||
Name = dataObj[AttrNames.User].ToString(),
|
Name = head[AttrNames.User].ToString(),
|
||||||
NickName = dataObj[AttrNames.NickName].ToString(),
|
NickName = head[AttrNames.NickName].ToString(),
|
||||||
Motto = dataObj[AttrNames.Motto].ToString(),
|
Motto = head[AttrNames.Motto].ToString(),
|
||||||
Group = (UserGroup)Enum.Parse(typeof(UserGroup), dataObj[AttrNames.UGroup].ToString())
|
Group = (UserGroup)Enum.Parse(typeof(UserGroup), dataObj[AttrNames.UGroup].ToString()),
|
||||||
|
Photo = User.DefaultPhoto
|
||||||
};
|
};
|
||||||
OnLoginDone?.Invoke(head, user);
|
if (int.Parse(head[AttrNames.Photo].ToString()) > 0)
|
||||||
|
{
|
||||||
|
MemoryStream ms = new MemoryStream(data);
|
||||||
|
user.Photo = Image.FromStream(ms);
|
||||||
|
} //用户头像数据
|
||||||
|
OnLoginDone?.Invoke(resultHead, user);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
+12
-2
@@ -9,13 +9,23 @@ namespace Interact
|
|||||||
//定义一则用户接收到的消息
|
//定义一则用户接收到的消息
|
||||||
public class Message
|
public class Message
|
||||||
{
|
{
|
||||||
|
public Message() { }
|
||||||
|
public Message(string text, User Receiver)
|
||||||
|
{
|
||||||
|
When = DateTime.Now;
|
||||||
|
From = User.Me;
|
||||||
|
To = Receiver;
|
||||||
|
Text = text;
|
||||||
|
}
|
||||||
|
|
||||||
/*保留
|
/*保留
|
||||||
public const UInt32 MaxHeadLength = 4096; //最大包头长度
|
public const UInt32 MaxHeadLength = 4096; //最大包头长度
|
||||||
public const UInt32 MaxMessageLength = 0x6400000; //最大数据长度
|
public const UInt32 MaxMessageLength = 0x6400000; //最大数据长度
|
||||||
*/
|
*/
|
||||||
public DateTime When { get; } //服务器接收时间
|
public DateTime When { get; } //服务器接收时间
|
||||||
public User From; //发送者
|
public User From; //消息发送者
|
||||||
public string Content; //消息内容
|
public User To; //消息接收者
|
||||||
|
public string Text; //消息内容
|
||||||
|
|
||||||
//将消息保存到数据库(保留)
|
//将消息保存到数据库(保留)
|
||||||
protected bool Save() { return false; }
|
protected bool Save() { return false; }
|
||||||
|
|||||||
+2
-1
@@ -10,7 +10,8 @@ namespace Interact
|
|||||||
//用户
|
//用户
|
||||||
public class User
|
public class User
|
||||||
{
|
{
|
||||||
public static User Me; //当前用户
|
public static User Me; //当前用户
|
||||||
|
public static Image DefaultPhoto; //默认头像
|
||||||
|
|
||||||
public string Name; //用户名
|
public string Name; //用户名
|
||||||
public string NickName; //昵称
|
public string NickName; //昵称
|
||||||
|
|||||||
Reference in New Issue
Block a user