|
@@ -8,6 +8,7 @@ using UnityEngine.UI;
|
|
|
|
|
|
public class User
|
|
|
{
|
|
|
+ enum GetUserFlags { CompanyID, UserID };
|
|
|
public uint id { get; set; }
|
|
|
public string name { get; set; }
|
|
|
public bool online { get; set; }
|
|
@@ -41,17 +42,55 @@ public class User
|
|
|
player.users_load = true;
|
|
|
}
|
|
|
|
|
|
+ public static void SendGetUsers()
|
|
|
+ {
|
|
|
+ SendGetUsersForCompany(Client.instance.company_id);
|
|
|
+ }
|
|
|
+
|
|
|
+ //companyId: 1 = Тайшет, 2 = Тестовая, 3 = Братское
|
|
|
+ public static void SendGetUsersForCompany(uint companyId)
|
|
|
+ {
|
|
|
+ List<byte> list = new List<byte>();
|
|
|
+ list.Add(47);
|
|
|
+ list.Add((byte)GetUserFlags.CompanyID);
|
|
|
+ list.AddRange(BitConverter.GetBytes(companyId));
|
|
|
+ Client.SendEnqueue(list.ToArray());
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void SendGetUser(uint userId)
|
|
|
+ {
|
|
|
+ List<byte> list = new List<byte>();
|
|
|
+ list.Add(47);
|
|
|
+ list.Add((byte)GetUserFlags.UserID);
|
|
|
+ list.AddRange(BitConverter.GetBytes(userId));
|
|
|
+ Client.SendEnqueue(list.ToArray());
|
|
|
+ }
|
|
|
+
|
|
|
+ public static User Find(uint id)
|
|
|
+ {
|
|
|
+ User user;
|
|
|
+ PlayerController.instance.users.TryGetValue(id, out user);
|
|
|
+ return user;
|
|
|
+ }
|
|
|
+
|
|
|
public static void LogInOut(byte[] bytedata)
|
|
|
{
|
|
|
var accid = BitConverter.ToUInt32(bytedata, 1);
|
|
|
var cmd = bytedata[5];
|
|
|
|
|
|
- var player = PlayerController.instance;
|
|
|
- var u = player.users[accid];
|
|
|
+ var u = User.Find(accid);
|
|
|
|
|
|
- var b = cmd != 0;
|
|
|
- u.toggle_user.SetActive(b);
|
|
|
- u.marker.SetActive(b);
|
|
|
+ if (u != null)
|
|
|
+ {
|
|
|
+ var b = cmd != 0;
|
|
|
+ u.toggle_user.SetActive(b);
|
|
|
+ u.marker.SetActive(b);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Debug.LogError($"LogInOut accid {accid} not found");
|
|
|
+ SendGetUser(accid);
|
|
|
+ }
|
|
|
|
|
|
Debug.Log($"LogInOut accid {accid} cmd {cmd}");
|
|
|
}
|