Advertisement
MaksNew

Untitled

May 17th, 2021
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using System.ServiceModel;
  2.  
  3. namespace CHAT
  4. {
  5.     public class ServerUser
  6.     {
  7.         public int ID { get; set; }
  8.         public string Name { get; set; }
  9.         public OperationContext operationContext { get; set; }
  10.     }
  11. }
  12.  
  13.  
  14. using System;
  15. using System.Collections.Generic;
  16. using System.Linq;
  17. using System.Runtime.Serialization;
  18. using System.ServiceModel;
  19. using System.Text;
  20.  
  21. namespace CHAT
  22. {
  23.     [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
  24.     public class Service1 : IService1
  25.     {
  26.         List<ServerUser> users = new List<ServerUser>();
  27.         int nextId = 1;
  28.         public int Connect(string name)
  29.         {
  30.             ServerUser user = new ServerUser();
  31.             {
  32.                 ID = nextId;
  33.                 Name = name;
  34.                 operationContext = OperationContext.Current;
  35.             };
  36.             ++nextId;
  37.             users.Add(user);
  38.             return user.ID;
  39.         }
  40.     }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement