0
私は単純なチャットルームのためのクライアントとサーバを持っているとしましょう。適切なクライアント<->サーバの通信
これらはJSON文字列で通信します。
私は次の例が安全ではないことを理解していますが、これが効率的な通信方法である場合にのみ私は興味があります。
// The Client connects to the server.
// The Client sends a JSON string with the following variables to the server:
--> Intention: "Request"
--> Context: "Login"
--> Message: "username:admin|password:123"
// The Server receives the JSON string and the string goes through an if-statement:
--> if(Intention.Equals("Request")){...}else if(Intention.Equals("Response")){...}
// The Server now knows it's a Request and moves on to the next step.
--> if(Context.Equals("Login")){.<check if user exists in server database and if the login details match>.}
// If the login details are correct, The Server marks the connected Client as logged in and sends a JSON string back to The Client:
--> Intention: "Response"
--> Context: "Login"
--> Message: "OK"
// The Client receives the messages and sees it's OK, now the Client shows the user control panel and chatbox to the user which all send other Request JSON strings to The Server.
// Any other context than "Login" check if the Client actually is marked as logged in, if not, the server returns a response with "ERR_NOT_LOGGED_IN"
今、私はいくつか質問があります。
- これは、クライアントとサーバーの間で前後に通信の効率的な/良い方法だろうか?
- 良い点と悪い点は何ですか?
- コミュニケーションをより良く/より効率的にするためのヒントがありますか?
- これは大企業のチャットサーバーであり、パスワードはプレーンテキストで保存されていませんが、秘密の&公開鍵で処理された場合、大きなセキュリティ上の欠陥は他にありますか?
私はクライアントとサーバーが通信するための良い方法について多くを見つけるので、私はではなく、実際のコンテンツについて、求めていますが、前後に送信されます。
ありがとうございます!