コード例 #1
0
ファイル: LaunchServer.cs プロジェクト: hnjm/Private-Chat
        public static void CreateUser(string username, string pass)
        {
            ClientProcessing cp = new ClientProcessing();
            int id = cp.AddActiveUser();

            cp.CreateUser(String.Format("Username:{0}$$Password:{1}$$UserIV:{0}$$", username, pass), id);
        }
コード例 #2
0
 public static void InvitationProcces(ClientProcessing cp, int fId, int sId)
 {
     Console.WriteLine("Add friend:   " + AddFriend(fId, "test1", cp));
     Console.WriteLine("Send invs:   " + SendInvitations(sId, cp));
     Console.WriteLine("Send invs:   " + SendInvitations(sId, cp));
     //Console.WriteLine("Decline friend:   " + DeclineFriend(sId, 1, cp));
     Console.WriteLine("Acc friend:   " + AcceptFriend(sId, 1, cp));
     Console.WriteLine("Send invs:   " + SendInvitations(sId, cp));
     Console.WriteLine("Send invs:   " + SendInvitations(fId, cp));
 }
コード例 #3
0
        public ServerConnection()
        {
            menager             = new ClientProcessing();
            userNewVoiceHandler = new Dictionary <IPAddress, EventWaitHandle>();
            voiceToSend         = new Dictionary <int, Dictionary <IPAddress, Queue <byte[]> > >();
            usersConversations  = new Dictionary <IPAddress, int>();
            receivingUdpClient  = new UdpClient(IP.serverPort);


            toSend = new Dictionary <int, Dictionary <IPAddress, ConcurrentQueue <byte[]> > >();
            conversationsParticipans = new Dictionary <int, ConcurrentBag <IPEndPoint> >();

            Task.Run(() => { UdpRead(); });
            RunServer();
        }
コード例 #4
0
        public static void StartTests()
        {
            ClientProcessing cp = new ClientProcessing();
            int fId             = cp.AddActiveUser();
            int sId             = cp.AddActiveUser();


            Console.WriteLine(RegisterUser(fId, "test", "haslo1", cp));
            Console.WriteLine(RegisterUser(sId, "test1", "haslo2", cp));

            Console.WriteLine(Login(fId, "test", "haslo1", cp));
            Console.WriteLine(Login(sId, "test1", "haslo2", cp));

            Console.WriteLine(CheckUsername(fId, "test1", cp));
            Console.WriteLine(CheckUsername(fId, "test2", cp));

            InvitationProcces(cp, fId, sId);
            //Console.WriteLine(DeclineFriend(fId, 1, cp));
        }
コード例 #5
0
ファイル: LaunchServer.cs プロジェクト: hnjm/Private-Chat
        public static void FriendsAddTest()
        {
            ClientProcessing cp = new ClientProcessing();
            int id  = cp.AddActiveUser();
            int id1 = cp.AddActiveUser();

            Console.WriteLine(cp.Login("Username:test1$$Password:test1234$$", id));
            Console.WriteLine(cp.Login("Username:test2$$Password:test1234$$", id1));

            string pk  = BigInteger.Parse("1572974685565517564760848834612061204603051782958757453266089894").ToString("X");
            string pri = BigInteger.Parse("2171516053468561523083790486470955343976023523132159054917711086").ToString("X");
            string iv  = BigInteger.Parse("48040271114089576525052332491161").ToString("X");

            Console.WriteLine(cp.AddFriend("SecondUserName:test2$$", id));
            Console.WriteLine(cp.DhExchange(String.Format("InvitationID:1$$PK:{0}$$PrivateK:{1}$$IV:{2}$$", pk, pri, iv), id));
            Console.WriteLine(cp.SendInvitations("", id1));
            Console.WriteLine(cp.AcceptFriend("InvitationID:1$$PKB:4$$", id1));
            Console.WriteLine(cp.SendConversationKey("ConversationID:1$$ConversationKey:ytyt$$", id1));


            Console.WriteLine(cp.SendAcceptedFriends("", id));
            Console.WriteLine(cp.SendConversationKey("ConversationID:1$$ConversationKey:ytyoit$$", id));
        }
コード例 #6
0
ファイル: LaunchServer.cs プロジェクト: hnjm/Private-Chat
        public static void MessageTest()
        {
            ClientProcessing cp = new ClientProcessing();
            int id  = cp.AddActiveUser();
            int id1 = cp.AddActiveUser();

            cp.Login("Username:test8$$Password:test1234$$", id);
            cp.Login("Username:test7$$Password:12345678$$", id1);


            Console.WriteLine(cp.ActivateConversation("ConversationID:6$$", id));
            Console.WriteLine(cp.NewMessages("", id));
            Message m = new Message {
                date = DateTime.Now, message = "test", username = "******"
            };
            string s = JsonConvert.SerializeObject(m);

            Console.WriteLine(cp.SendMessage(String.Format("Username:test7$$Data:{0}$$", s), id));
            Console.WriteLine(cp.SendMessage(String.Format("Username:test7$$Data:{0}$$", s), id));
            Console.WriteLine(cp.Notification("", id1));
            Console.WriteLine(cp.Notification("", id1));
            Console.WriteLine(cp.ActivateConversation("ConversationID:6$$", id1));
            Console.WriteLine(cp.NewMessages("", id1));
        }
コード例 #7
0
 public static string SendInvitations(int clientId, ClientProcessing cp)
 {
     return(cp.SendInvitations(clientId, "test1"));
 }
コード例 #8
0
 public static string DeclineFriend(int clientId, int invitationId, ClientProcessing cp)
 {
     return(cp.DeclineFriend(MessageProccesing.CreateMessage <Id>(Options.DECLINE_FRIEND, new Id(invitationId)), clientId));
 }
コード例 #9
0
 public static string AcceptFriend(int clientId, int invitationId, ClientProcessing cp)
 {
     return(cp.AcceptFriend(MessageProccesing.CreateMessage <Id>(Options.ACCEPT_FRIEND, new Id(invitationId)), clientId));
 }
コード例 #10
0
 public static string AddFriend(int clientId, string username, ClientProcessing cp)
 {
     return(cp.AddFriend(MessageProccesing.CreateMessage <Username>(Options.ADD_FRIEND, new Username(username)), clientId));
 }
コード例 #11
0
 public static string CheckUsername(int clientId, string name, ClientProcessing cp)
 {
     return(cp.CheckUserName(MessageProccesing.CreateMessage <Username>(Options.CHECK_USER_NAME, new Username(name)), clientId));
 }
コード例 #12
0
 public static string Login(int clientId, string name, string password, ClientProcessing cp)
 {
     return(cp.Login(MessageProccesing.CreateMessage <Login>(Options.LOGIN, new Login(name, password)), clientId));
 }
コード例 #13
0
 public static string RegisterUser(int clientId, string name, string password, ClientProcessing cp)
 {
     return(cp.CreateUser(MessageProccesing.CreateMessage <Login>(Options.CREATE_USER, new Login(name, password)), clientId));
 }
コード例 #14
0
 public ServerConnection()
 {
     menager = new ClientProcessing();
     RunServer();
 }