goChat

package module
v0.0.0-...-79c1cee Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2017 License: MIT Imports: 5 Imported by: 4

README

Go Chat GoDoc Build Status

A client-server chat app implemented in Go using gRPC.

Usage

Server

Start the server by running go run server.go. Alternatively, you can run go build while in the Server directory.

Client

Start the client(s) by running go run client.go menu.go. Alternatively, you can run go build while in the Client directory.

To run navigate the client:

  • First enter the server ip:port exactly. It is likely localhost:12021 unless the port at the top of server.go has changed.
  • Then you'll enter a username that is yours for the session.
  • Finally, you are greeted by the menu system which will allow you to create, join, or view other members and groups.

Known Bugs

  • None currently. If you run into any problems, please don't hesistate to create an issue.

Notes

  • To disconnect from the server, press ctrl+c or type !exit (hit enter) and the client will disconnect from the server.
  • To move backwards in the menu system, you can type !back (hit enter).
  • This client/server assumes a 12021 server port. This can be changed in the server.go file near the top.

Future Ideas

  • The !leave function to leave a chat and go back to the main menu.
  • Encryption on chat channels.
  • Ability to send files.
  • Complete server re-write to be more extendible and understandable.

Documentation

Overview

Package goChat is a generated protocol buffer package.

It is generated from these files:

services.proto

It has these top-level messages:

Empty
ChatMessage
ClientInfo
GroupInfo
GroupList
ClientList

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterChatServer

func RegisterChatServer(s *grpc.Server, srv ChatServer)

Types

type ChatClient

type ChatClient interface {
	RouteChat(ctx context.Context, opts ...grpc.CallOption) (Chat_RouteChatClient, error)
	UnRegister(ctx context.Context, in *ClientInfo, opts ...grpc.CallOption) (*Empty, error)
	Register(ctx context.Context, in *ClientInfo, opts ...grpc.CallOption) (*Empty, error)
	CreateGroup(ctx context.Context, in *GroupInfo, opts ...grpc.CallOption) (*Empty, error)
	JoinGroup(ctx context.Context, in *GroupInfo, opts ...grpc.CallOption) (*Empty, error)
	GetGroupList(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*GroupList, error)
	GetGroupClientList(ctx context.Context, in *GroupInfo, opts ...grpc.CallOption) (*ClientList, error)
	GetClientList(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*ClientList, error)
	LeaveRoom(ctx context.Context, in *GroupInfo, opts ...grpc.CallOption) (*Empty, error)
}

func NewChatClient

func NewChatClient(cc *grpc.ClientConn) ChatClient

type ChatMessage

type ChatMessage struct {
	Sender   string `protobuf:"bytes,1,opt,name=sender" json:"sender,omitempty"`
	Receiver string `protobuf:"bytes,2,opt,name=receiver" json:"receiver,omitempty"`
	Message  string `protobuf:"bytes,3,opt,name=message" json:"message,omitempty"`
}

func (*ChatMessage) Descriptor

func (*ChatMessage) Descriptor() ([]byte, []int)

func (*ChatMessage) GetMessage

func (m *ChatMessage) GetMessage() string

func (*ChatMessage) GetReceiver

func (m *ChatMessage) GetReceiver() string

func (*ChatMessage) GetSender

func (m *ChatMessage) GetSender() string

func (*ChatMessage) ProtoMessage

func (*ChatMessage) ProtoMessage()

func (*ChatMessage) Reset

func (m *ChatMessage) Reset()

func (*ChatMessage) String

func (m *ChatMessage) String() string

type ChatServer

type ChatServer interface {
	RouteChat(Chat_RouteChatServer) error
	UnRegister(context.Context, *ClientInfo) (*Empty, error)
	Register(context.Context, *ClientInfo) (*Empty, error)
	CreateGroup(context.Context, *GroupInfo) (*Empty, error)
	JoinGroup(context.Context, *GroupInfo) (*Empty, error)
	GetGroupList(context.Context, *Empty) (*GroupList, error)
	GetGroupClientList(context.Context, *GroupInfo) (*ClientList, error)
	GetClientList(context.Context, *Empty) (*ClientList, error)
	LeaveRoom(context.Context, *GroupInfo) (*Empty, error)
}

type Chat_RouteChatClient

type Chat_RouteChatClient interface {
	Send(*ChatMessage) error
	Recv() (*ChatMessage, error)
	grpc.ClientStream
}

type Chat_RouteChatServer

type Chat_RouteChatServer interface {
	Send(*ChatMessage) error
	Recv() (*ChatMessage, error)
	grpc.ServerStream
}

type ClientInfo

type ClientInfo struct {
	Sender string `protobuf:"bytes,1,opt,name=sender" json:"sender,omitempty"`
}

func (*ClientInfo) Descriptor

func (*ClientInfo) Descriptor() ([]byte, []int)

func (*ClientInfo) GetSender

func (m *ClientInfo) GetSender() string

func (*ClientInfo) ProtoMessage

func (*ClientInfo) ProtoMessage()

func (*ClientInfo) Reset

func (m *ClientInfo) Reset()

func (*ClientInfo) String

func (m *ClientInfo) String() string

type ClientList

type ClientList struct {
	Clients []string `protobuf:"bytes,1,rep,name=clients" json:"clients,omitempty"`
}

func (*ClientList) Descriptor

func (*ClientList) Descriptor() ([]byte, []int)

func (*ClientList) GetClients

func (m *ClientList) GetClients() []string

func (*ClientList) ProtoMessage

func (*ClientList) ProtoMessage()

func (*ClientList) Reset

func (m *ClientList) Reset()

func (*ClientList) String

func (m *ClientList) String() string

type Empty

type Empty struct {
}

func (*Empty) Descriptor

func (*Empty) Descriptor() ([]byte, []int)

func (*Empty) ProtoMessage

func (*Empty) ProtoMessage()

func (*Empty) Reset

func (m *Empty) Reset()

func (*Empty) String

func (m *Empty) String() string

type GroupInfo

type GroupInfo struct {
	Client    string `protobuf:"bytes,1,opt,name=client" json:"client,omitempty"`
	GroupName string `protobuf:"bytes,2,opt,name=groupName" json:"groupName,omitempty"`
}

func (*GroupInfo) Descriptor

func (*GroupInfo) Descriptor() ([]byte, []int)

func (*GroupInfo) GetClient

func (m *GroupInfo) GetClient() string

func (*GroupInfo) GetGroupName

func (m *GroupInfo) GetGroupName() string

func (*GroupInfo) ProtoMessage

func (*GroupInfo) ProtoMessage()

func (*GroupInfo) Reset

func (m *GroupInfo) Reset()

func (*GroupInfo) String

func (m *GroupInfo) String() string

type GroupList

type GroupList struct {
	Groups []string `protobuf:"bytes,1,rep,name=groups" json:"groups,omitempty"`
}

func (*GroupList) Descriptor

func (*GroupList) Descriptor() ([]byte, []int)

func (*GroupList) GetGroups

func (m *GroupList) GetGroups() []string

func (*GroupList) ProtoMessage

func (*GroupList) ProtoMessage()

func (*GroupList) Reset

func (m *GroupList) Reset()

func (*GroupList) String

func (m *GroupList) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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