Each chat room provides a chat function to facilitate those chat friends who need to communicate privately. here we will introduce the methods for implementing private chat in my chat room as follows: 1. process each message
Each chat room provides a chat function to facilitate those chat friends who need to communicate privately. here we will introduce the methods for implementing private chat in my chat room as follows:
1. processing of sent information
Every private chat is displayed on the screen of the user and the private chat object, and others cannot see it. here, we will process the speech content and save it in the speech file!
- // $ Split is the separator
- Messagesend. php
-
- // Determine whether to speak privately
- If ($ secret = "on ")
- {
- // Mark the speech + Indicates the delimiter.
- // The first one marked as secret indicates private chat, followed by the chat object and its own name, so that the two can see
- $ Message =" Password $ message ";
- }
- Else
- {
- // If the first object is marked as "open", the object and its own name will be followed.
- $ Message =" $ Message ";
- }
- // Save it to the file
- ?>
2. private chat display method
Process and judge each new speech after reading it, and execute messageflush. php in the active refresh program.
-
- // Separate the speech content
- $ Tempmessage = split ($ split, $ message [0], 99 );
- // If the speaker is not a private conversation, or the target user is a private chat, or the user who sends the private chat is himself, this sentence is displayed; otherwise, it is not displayed.
- If ($ tempmessage [1]! = "Secret") | ($ tempmessage [2] = $ name) | (
- $ Tempmessage [3] = $ name ))
- {
- // Display private chat
- Print ("parent.u.doc ument. writeln (" $ message [0] ");");
- }
- ?>
This simple method enables private chat.
Note:Before saving the file for processing, there are In this way, you don't have to deal with it on the screen!