class Server
This class represents a server that manages the encryption keys, and maintains a list of currently connected clients. It is also responsible for handling message transmission between the clients.
attributes
clientSet: ClientSet
operation specifications
+ Server ( )
-- constructor
pre: none
post: A ClientSet object has been created and assigned to clientSet.
+ addClient (client: Client)
-- adds a new client to the clientSet.
pre: client not null
post: client is added to the clientSet.
For all clients in clientSet, the updateConnectedUsers message has been sent.
+ disconnectClient (id: Integer)
-- deletes the client with matching id from the clientSet and sends a message to each client informing them of the update to the list of connected users.
pre: none
post: The client object with matching id is deleted from the clientSet.
For all clients in the clientSet, the updateConnectedUsers message has been sent.
+ establishSession (nameC1: String, nameC2: String): SessionData
-- After generating a random session key for C1 and C2 to communicate to each other, it encrypts two copies of it: one in C1’s key and the other in C2’s key. Then, it sends the session data for C2 to C2. It returns the session data for C1.
pre: nameC1 and nameC2 are valid
post: The random session key has been generated and encrypted for both clients.
sessionData for C2 has been created and sent to C2 by sending the message
acceptSessionData(sessionData)
sessionData for C1 has been returned.
+ sendCmd (cmd: String, sessionId: Integer, nameC2: String)
-- transmits a command message from C1 to C2.
pre: cmd valid
post: The command message received from C1 has been sent to C2 by sending the
message acceptCmd(cmd, sessionId)
+ sendChatMsg (text: String, sessionId: Integer, nameC2: String)
-- transmits a chat message from C1 to C2.
pre:
post: The chat message received from C1 has been sent to C2 by
sending the message acceptChatMessage(text, sessionId)
- generateRandomKey (): String
-- Generates a random session key.
pre: none
post: A valid session key is returned, which contains one or more capital letters that
have an ASCII value between 65 and 90.
Encrypted Chat Room 4_Class Specifications(4)
最新推荐文章于 2007-01-10 14:26:00 发布
博客介绍了Server类,该类管理加密密钥、维护客户端列表并处理客户端间消息传输。详细说明了其属性clientSet,以及多个操作规范,如添加、断开客户端,建立会话,发送命令和聊天消息等,还包含生成随机会话密钥的方法。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
Llama Factory
模型微调
LLama-Factory
LLaMA Factory 是一个简单易用且高效的大型语言模型(Large Language Model)训练与微调平台。通过 LLaMA Factory,可以在无需编写任何代码的前提下,在本地完成上百种预训练模型的微调
1189

被折叠的 条评论
为什么被折叠?



