Created signalCode and replyCode types
This commit is contained in:
parent
b75bb0dacd
commit
fd94747c9b
10
client.go
10
client.go
@ -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:
|
||||
|
14
rosella.go
14
rosella.go
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user