浏览代码

socket

ZhangXueYang
zhangxueyang 3 年前
父节点
当前提交
1e65ea760c

+ 4
- 1
XHZB.DAL/Class1.cs 查看文件

@@ -41,13 +41,16 @@ namespace XHZB.DAL
41 41
                         Message = "无法访问文件服务器,请检查网络或文件服务器地址。";
42 42
                         return false;
43 43
                     }
44
+                    //string retString = "";
45
+                    //JObject.Parse(retString);
46
+                    //string str = jo["c"].ToString();
44 47
                     //Model.ResultVo<Model_ResourceAddTwo> resultObj = JsonHelper.JsonToObj<Model.ResultVo<Model_ResourceAddTwo>>(jo.ToString());
45 48
                     //APP.ResourceAddTwo = new Model_ResourceAddTwo();
46 49
                     ////0成功,1失败
47 50
                     //if (resultObj.code == 0 && resultObj.obj != null)
48 51
                     //{
49 52
                     //    APP.ResourceAddTwo = resultObj.obj;
50
-                        
53
+
51 54
                     //    return true;
52 55
                     //}
53 56
                     //else

+ 3
- 1
XHZB.Desktop/ToolbarWindow.xaml.cs 查看文件

@@ -44,6 +44,7 @@ namespace XHZB.Desktop
44 44
         /// 是否已打开课堂工具二级列表
45 45
         /// </summary>
46 46
         private bool heibanshow = false;
47
+        private bool isTool = true;
47 48
         #endregion
48 49
 
49 50
         #region 初始化
@@ -146,8 +147,9 @@ namespace XHZB.Desktop
146 147
             {
147 148
                 //HideLevel2();
148 149
                 pageData.tongping = !pageData.tongping;
149
-                if (pageData.tongping)
150
+                if (pageData.tongping&& isTool)
150 151
                 {
152
+                    isTool = false;
151 153
                     //tongpingBegin();
152 154
                     if (StartLive(out string ErrMessage))
153 155
                     {

+ 34
- 0
XHZB.Desktop/WebSocket/WSocketClient.cs 查看文件

@@ -1,4 +1,5 @@
1 1
 using Common.system;
2
+using Newtonsoft.Json.Linq;
2 3
 using SuperSocket.ClientEngine;
3 4
 using System;
4 5
 using System.Collections.Generic;
@@ -117,12 +118,45 @@ namespace XHZB.Desktop.WebSocket
117 118
             MessageReceived?.Invoke(e.Message);
118 119
 
119 120
             Console.WriteLine("WS:消息收到:" + e.Message);
121
+            //string str = e.Message;
122
+            //  JObject.Parse(str);
123
+            //string str = jo["c"].ToString();
120 124
 
121 125
 
122 126
             SocketModel msgBean = JsonHelper.JsonToObj<SocketModel>(e.Message);
123 127
 
128
+           //if(isMsg)
129
+           // {
130
+           //     GetOnlineStudentsModel msgBean = JsonHelper.JsonToObj<GetOnlineStudentsModel>(e.Message);
131
+           //     if (msgBean.c == 1040)
132
+           //     {
133
+
134
+           //     }
135
+           // }
136
+
124 137
             if (msgBean != null && msgBean.b != null)
125 138
             {
139
+                if(msgBean.c==1040)
140
+                {
141
+                    GetOnlineStudentsModel msgOnline= JsonHelper.JsonToObj<GetOnlineStudentsModel>(e.Message);
142
+
143
+                    foreach(StudentModel getOnline in msgOnline.b.stulst)
144
+                    {
145
+                        OnlineUserModel item = new OnlineUserModel
146
+                        {
147
+                            usertype = 2001,
148
+                            userid = getOnline.userid,
149
+                            username = getOnline.username,
150
+                            userpic = getOnline.headportrait
151
+                        };
152
+                        APP.OnlineUserList.Add(item);
153
+                    }
154
+
155
+                    //GetOnlineStudentsModel get = new GetOnlineStudentsModel();
156
+                    //get.b = new StulstModel();
157
+                   
158
+                    //Console.WriteLine("WS:消息收到1111:" + get);
159
+                }
126 160
                 if (msgBean.c != 0&& msgBean.u == 2)
127 161
                 {
128 162
                     if (msgBean.c == 2001)//上线

+ 18
- 0
XHZB.Model/GetOnlineStudentsModel.cs 查看文件

@@ -0,0 +1,18 @@
1
+
2
+using System.Collections.Generic;
3
+
4
+namespace XHZB.Model
5
+{
6
+    public class GetOnlineStudentsModel
7
+    {
8
+        public int c { get; set; }
9
+        public string d { get; set; }
10
+        public int f { get; set; }
11
+        public int rid { get; set; }
12
+        public int s { get; set; }
13
+        public List<int> t { set; get; }
14
+        public int u { get; set; }
15
+
16
+        public StulstModel b { get; set; } 
17
+    }
18
+}

+ 18
- 0
XHZB.Model/StudentModel.cs 查看文件

@@ -0,0 +1,18 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace XHZB.Model
8
+{
9
+    public class StudentModel
10
+    {
11
+        /// <summary>
12
+        /// 头像
13
+        /// </summary>
14
+        public string headportrait { get; set; }
15
+        public int userid { get; set; }
16
+        public string username { get; set; }
17
+    }
18
+}

+ 15
- 0
XHZB.Model/StulstModel.cs 查看文件

@@ -0,0 +1,15 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace XHZB.Model
8
+{
9
+    public class StulstModel
10
+    {
11
+
12
+        public List<StudentModel> stulst { get; set; }
13
+   
14
+    }
15
+}

+ 3
- 0
XHZB.Model/XHZB.Model.csproj 查看文件

@@ -49,6 +49,7 @@
49 49
     <Compile Include="ClassStudentListModel.cs" />
50 50
     <Compile Include="ComboBoxBeanModel.cs" />
51 51
     <Compile Include="DirectorListModel.cs" />
52
+    <Compile Include="GetOnlineStudentsModel.cs" />
52 53
     <Compile Include="LoginModel.cs" />
53 54
     <Compile Include="NotifyModel.cs" />
54 55
     <Compile Include="OnlineUserModel.cs" />
@@ -59,6 +60,8 @@
59 60
     <Compile Include="RollCallModel.cs" />
60 61
     <Compile Include="SavefileModel.cs" />
61 62
     <Compile Include="SocketModel.cs" />
63
+    <Compile Include="StudentModel.cs" />
64
+    <Compile Include="StulstModel.cs" />
62 65
     <Compile Include="TsubjectbookListModel.cs" />
63 66
     <Compile Include="ZBMenuModel.cs" />
64 67
     <Compile Include="ZBPageModel.cs" />

正在加载...
取消
保存