|
8 years ago | |
---|---|---|
README.md | 8 years ago | |
app.js | 8 years ago | |
package.json | 8 years ago |
README.md
Public-Chat
Public Chat is a simple chat made with NodeJS and Socket.io.
Documentation Public Chat
Côté Client:
Si vous souhaitez intégrer Public Chat à votre site, vous allez avoir besoin de certaines choses:
- Importez Jquery dans des balises script : http://code.jquery.com/jquery-1.10.1.min.js
- Importez socket.io dans des balises script : http://92.222.24.154:8080/socket.io/socket.io.js
- Importez Jquery UI dans des balises script : http://code.jquery.com/ui/1.11.4/jquery-ui.js
- Importez Public-Chat script dans des balises script: http://playandcode.ml/chat/chat.js
Maintenant, vous allez avoir besoin de certains conteneurs pour accueillir votre chat:
-
Commencez par le Peudo_wrapper, c'est ici que le client va entrer ses informations : Pseudo, IP, Port, Mot de passe:
<div id="pseudo_wrapper" style="display:none;" class="row"> <input type="text" name="name" id="pseudo" placeholder="Pseudo (max. 15 char.)" class="four columns"> <input type="text" name="name" id="server" placeholder="IP" class="three columns" value="92.222.24.154"> <input type="text" name="name" id="port" placeholder="PORT" value="8080" class="two columns"> <input type="password" name="name" id="mdp" placeholder="MDP" class="two columns"> <button type="button" name="button" onclick="entered()" class="two columns">OK</button> </div>
Les classes ne sont pas obligatoires
-
Ensuite, il va vous falloir une section dans laquelle vont s'afficher les clients:
<div id="clients"> Serveur par defaut : 92.222.24.154:8080 -- Pas de mot de passe </div>
-
Il vous faut ensuite de quoi afficher les messages:
<div id="chat_content"></div>
-
Enfin, il vous faut un endroi où le client peut écrire son message:
<div id="form-container" style="display:none;> <form action="/" method="post" id="formulaire_chat"> <input type="text" name="message" id="message" placeholder="Message (Max. 150 charactères)" autofocus autocomplete="off" onkeydown="countChar(this)" onkeyup="countChar(this)" /> <input type="submit" id="envoi_message" class="button-primary"/> <span id="charNum"></span> </form> </div>
Les classes ne sont pas obligatoires
Côté Serveur:
Si vous souhaitez héberger votre propre serveur Public-Chat, suivez les instructions suivantes:
-
Téléchargez le côté serveur : Cliquez ici
-
Installez NodeJS sur votre machine (ordinateur ou serveur dédié)
-
Ouvrez la console, naviguez vers l'emplacement où se trouve le fichier serveur
-
Faites la commande
npm install
pour installer toutes les dépendances -
Ouvrez le fichier
app.js
et modifiez les valeurs de la variableconfig
à votre guise:var config = { name:"Official public chat", // Name of your chat motd:"Bienvenue sur le serveur officiel de Public Chat", // Description of your chat chatTimeout:"2000", // Minimum time between two messages color:"purple", //Server color in chat defaultName:"Anonyme", //Default name if client did not enter one maxLastMsgs:5, // Maximum messages saved maxClients:0, // 0 for unlimited clients password:0, // 0 for no password PORT:8080, // Port on which your server will be running seeMsgs:true // True to see all messages, false to hide all in console };
-
Lancez votre serveur en entrant la commande
node app.js
. Vous devriez avoir un affichage comme celui-ci:\
Si vous obtenez une erreur, assurez-vous de bien avoir effectué la commandenpm install
auparavant. Voici un exemple d'erreur que vous pourriez obtenir :\
Licence:
Copyright (c) <2015-2015> Freddy Nawfal - http://playandcode.ml - zefreddy.na@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.