Created signalCode and replyCode types

This commit is contained in:
Harry Jeffery 2013-08-24 20:58:38 +01:00
parent b75bb0dacd
commit fd94747c9b
3 changed files with 15 additions and 11 deletions

View File

@ -100,7 +100,7 @@ func (c *Client) disconnect() {
}
//Send a reply to a user with the code specified
func (c *Client) reply(code int, args ...string) {
func (c *Client) reply(code replyCode, args ...string) {
if c.connected == false {
return
}
@ -158,8 +158,8 @@ func (c *Client) reply(code int, args ...string) {
}
func (c *Client) clientThread() {
readSignalChan := make(chan int, 3)
writeSignalChan := make(chan int, 3)
readSignalChan := make(chan signalCode, 3)
writeSignalChan := make(chan signalCode, 3)
writeChan := make(chan string, 100)
go c.readThread(readSignalChan)
@ -196,7 +196,7 @@ func (c *Client) clientThread() {
}
func (c *Client) readThread(signalChan chan int) {
func (c *Client) readThread(signalChan chan signalCode) {
for {
select {
case signal := <-signalChan:
@ -226,7 +226,7 @@ func (c *Client) readThread(signalChan chan int) {
}
}
func (c *Client) writeThread(signalChan chan int, outputChan chan string) {
func (c *Client) writeThread(signalChan chan signalCode, outputChan chan string) {
for {
select {
case signal := <-signalChan:

View File

@ -14,7 +14,7 @@ type Server struct {
type Client struct {
server *Server
connection net.Conn
signalChan chan int
signalChan chan signalCode
outputChan chan string
nick string
registered bool
@ -34,12 +34,16 @@ type Channel struct {
clientMap map[string]*Client
}
const (
signalStop int = iota
)
type signalCode int
const (
rplWelcome int = iota
signalStop signalCode = iota
)
type replyCode int
const (
rplWelcome replyCode = iota
rplJoin
rplPart
rplTopic

View File

@ -32,7 +32,7 @@ func (s *Server) HandleConnection(conn net.Conn) {
client := &Client{server: s,
connection: conn,
outputChan: make(chan string),
signalChan: make(chan int, 3),
signalChan: make(chan signalCode, 3),
channelMap: make(map[string]*Channel),
connected: true}