Skip to content

Commit

Permalink
Merge pull request #10 from composer22/feature/client
Browse files Browse the repository at this point in the history
Javascript and README cleanups
  • Loading branch information
composer22 committed Apr 26, 2015
2 parents 45ffee7 + ed7e49d commit 96a7700
Show file tree
Hide file tree
Showing 9 changed files with 276 additions and 257 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# chattypantz
[![License MIT](https://img.shields.io/npm/l/express.svg)](http://opensource.org/licenses/MIT)
[![Build Status](https://travis-ci.org/composer22/chattypantz.svg?branch=master)](http://travis-ci.org/composer22/chattypantz)
[![Current Release](https://img.shields.io/badge/release-v0.1.0-brightgreen.svg)](https://github.com/composer22/chattypantz/releases/tag/v0.1.0)
[![Current Release](https://img.shields.io/badge/release-v0.1.1-brightgreen.svg)](https://github.com/composer22/chattypantz/releases/tag/v0.1.1)
[![Coverage Status](https://coveralls.io/repos/composer22/chattypantz/badge.svg?branch=master)](https://coveralls.io/r/composer22/chattypantz?branch=master)

![chattypantz-logo](assets/img/chattypantz.png)
Expand All @@ -10,14 +10,16 @@ A demo chat server and client written in [Go.](http://golang.org)

## About

This is a small server and client that demonstrates some Golang network socket functions and features.
This is a small chat server and client that demonstrates Golang network socket functions and features.

Some key objectives in this demonstration:

* Clients connect to the server on ws://{host:port}
* Messages sent by a client are broadcasted to other clients connected to the same chat room.
* The server only supports JSON text messages. Binary websocket frames will be discarded and the clients sending those frames will be disconnected with a message.
* When a client connects to a chat room, the server broadcasts "{nickname} has joined the room." to clients that were already connected to the same chat room.
* Clients should be able to join multiple rooms at the same time.
* A client can join a room as "hidden". When in "hidden" mode, the client can monitor room messages but cannot send messages. A client should be able to change this setting as needed.
* When a client disconnects, the server broadcasts "{nickname} has left the room." to clients connected to the same chat room.
* An unlimited amount of chat rooms can be created on the server (unless it runs out of memory or file descriptors).
* An unlimited amount of clients can join each chat room on the server (unless it runs out of memory or file descriptors).
Expand All @@ -30,7 +32,6 @@ Some key objectives in this demonstration:
Future objectives:

* Chat history for each room should be stored in a file. When the user logs in to a room, the history should be provided to the client. A max history option should be provided.
* More sophisticated client example code in html and js.

## Usage

Expand Down Expand Up @@ -63,8 +64,11 @@ Examples:
# 10 clients; 50 rooms; one hour idle allowed; 2 processors
chattypantz -N "San Francisco" -H 0.0.0.0 -p 6661 -n 10 -r 50 -i 3600 -X 2
# or simply:
chattypantz -N "San Francisco"
```
## Client Connection and demonstration
## Client Connection Specifications

The socket connection endpoint is:
```
Expand Down Expand Up @@ -119,6 +123,10 @@ Spaces must be encoded in JSON calls.
/disconnect
```

A client javascript/html demo is provided under the /client directory.
Please see that directories README.md for more information.

## HTTP API for Alive and Stats

Two additional API routes are provided:
Expand Down Expand Up @@ -170,8 +178,12 @@ A prebuilt docker image is available at (http://www.docker.com) [chattypantz](ht
If you have docker installed, run:
```
docker pull composer22/chattypantz:latest
or
docker pull composer22/chattypantz:<version>
if available.
```
See /docker directory README for more information on how to run it.

Expand Down
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

# Backlog
- [ ] Enable history for each room and load n-ary records from that log.
- [ ] More sophisticated client example code.
51 changes: 28 additions & 23 deletions client/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,45 @@
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Chattypantz Client Demo</title>
<meta name="description" content="A client demo for Chattypantz Chat Server">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.12.0/semantic.min.css"/>
<link rel="stylesheet" href="styles/main.css">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Chattypantz Client Demo</title>
<meta name="description" content="A client demo for Chattypantz Chat Server">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.12.0/semantic.min.css" />
<link rel="stylesheet" href="styles/main.css">
</head>

<body ng-app="chattypantzApp">
<!--[if lt IE 7]>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div class="ui page grid">
<div class="ui page grid">
<div class="ui header">
<h3 class="text-muted">ChattyPantz Client Demo</h3>
<h3 class="text-muted">ChattyPantz Client Demo</h3>
</div>
<div ng-view=""></div>
</div>
</div>

<!--[if lt IE 9]>
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.1.1/es5-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/json3/3.3.2/json3.min.js"></script>
<![endif]-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.12.0/semantic.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-resource.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-cookies.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-sanitize.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-route.min.js"></script>
<script src="scripts/app.js"></script>
<script src="scripts/controllers/main.js"></script>
<script src="scripts/services/api.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.12.0/semantic.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-resource.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-cookies.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-sanitize.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-route.min.js"></script>
<script src="scripts/app.js"></script>
<script src="scripts/controllers/main.js"></script>
<script src="scripts/services/api.js"></script>
</body>

</html>
18 changes: 9 additions & 9 deletions client/app/scripts/app.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';

angular.module('chattypantzApp', ['ngCookies', 'ngResource', 'ngSanitize', 'ngRoute']).config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl'
})
.otherwise({
redirectTo: '/'
});
angular.module('chattypantzApp', ['ngCookies', 'ngResource', 'ngSanitize', 'ngRoute']).config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl'
})
.otherwise({
redirectTo: '/'
});
});
Loading

0 comments on commit 96a7700

Please sign in to comment.