goroomchat

package module
v0.0.0-...-f2519a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2019 License: GPL-3.0 Imports: 9 Imported by: 0

README

Go ROOM CHAT

library ini adalah hasil pengembangan dari chat app webscoket noval agung, untuk dokumentasi asli klik disini. dalam library ini semua chat akan disimpan dalam log dengan nama chat.txt. user dapat berkomunikasi dengan cara private chat atau group.

Features

  • percakapan dilakukan dengan cara private chat atau group chat
  • chat tersimpan ke dalam log, log ini digunakan untuk mengambil chat yang sebelumnya ketika halaman tertutup atau melakukan refresh

INSTALASI

  1. clone repository ini
  2. ambil gorilla/websocket go get github.com/gorilla/websocket
  3. ambil gubrak dari noval agung go get -u github.com/novalagung/gubrak

Menjalankan Contoh

masuk ke folder example lalu ketikan "go run example.go" .disini host yang digunakan localhost dengan port 8080 hal ini bisa disesuaikan untuk pengaksesan chat :

  • private chat localhost:8080?to= (nama user) misal : localhost:8080?to=admin
  • group chat localhost:8080/(nama group) misal : localhost:8080/grupa/
  • untuk melihat group yang aktif dan tersedia localhost:8080/rooms/

Thanks

Noval Agung - tutorial web socket

Contact

jika terdapat pertanyaan dapat email dengan subjek goroomchat ke fabarj4@gmail.com

Documentation

Index

Constants

View Source
const MESSAGE_CHAT = "chat"
View Source
const MESSAGE_LEAVE = "leave"
View Source
const MESSAGE_LOG = "log"
View Source
const MESSAGE_NEW_LOGIN = "new_login"

Variables

This section is empty.

Functions

func GetRooms

func GetRooms() map[string][]*WebSocketConnection

func HandleRooms

func HandleRooms(w http.ResponseWriter, r *http.Request)

func HandleWS

func HandleWS(w http.ResponseWriter, r *http.Request)

Types

type M

type M map[string]interface{}

type Rooms

type Rooms struct {
	Name   string `json:"name"`
	Status string `json:"status"`
}

type SocketPayload

type SocketPayload struct {
	From    string `json:"from"`
	Message string `json:"message"`
	Room    string `json:"room"`
	To      string `json:"to"`
	Type    string `json:"type"`
}

type SocketResponse

type SocketResponse struct {
	User    string `json:"user"`
	From    string `json:"from"`
	Type    string `json:"type"`
	Message string `json:"message"`
	Room    string `json:"room"`
	To      string `json:"to"`
}

type WebSocketConnection

type WebSocketConnection struct {
	*websocket.Conn
	Username string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL