Skip to content
/ d2client Public

Client able to write and read data over TCP on a Diablo II server.

License

Notifications You must be signed in to change notification settings

nokka/d2client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Diablo II TCP client

Go Report Card GoDoc

D2Client is a TCP client that logs into the Diablo II server and can then write messages to the server, both in the chat and whisper specific accounts.

Message example

Install

$ go get github.com/nokka/d2client

Usage

package main

import (
	"fmt"
	"log"

	"github.com/nokka/d2client"
)

func main() {
	client := d2client.New()
	client.Open("private.server:3001")
	defer client.Close()

	// Setup channel to read on.
	ch := make(chan []byte)

	// Setup output error channel.
	errors := make(chan error)

	client.Read(ch, errors)

	err := client.Login("user", "password")
	if err != nil {
		log.Fatal(err)
	}

	client.Whisper("nokka", "Hello!")


	// Read the output from the chat onto a channel.
	for {
		select {
		// This case means we recieved data on the connection.
		case data := <-ch:
			fmt.Println(string(data))

		case err := <-errors:
			fmt.Println(err)
			break
		}
	}
}

Contributing

Please see CONTRIBUTING.md.

About

Client able to write and read data over TCP on a Diablo II server.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages