Merge pull request 'Testing review' (#1) from test_review into master
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: http://git.tfm.ro/mihaim/elbot/pulls/1
This commit is contained in:
commit
f82435fe2b
2
TODO.md
2
TODO.md
@ -13,3 +13,5 @@
|
||||
* /set buy item <ITEM> <QUANTITY> <PRICE>
|
||||
* /set sell item <ITEM> <QUANTITY> <PRICE>
|
||||
* /get wanted
|
||||
|
||||
## Things for web interface
|
||||
|
||||
14
main.go
14
main.go
@ -154,8 +154,6 @@ func processPmMessage(c net.Conn, user string, mesaj string) {
|
||||
|
||||
func processBuffer(c net.Conn, buffer []byte, length int) {
|
||||
|
||||
ping_reply := make([]byte, 7)
|
||||
|
||||
switch buffer[0] {
|
||||
|
||||
// received inventory
|
||||
@ -173,16 +171,8 @@ func processBuffer(c net.Conn, buffer []byte, length int) {
|
||||
// Ping from server
|
||||
case PING_REQUEST:
|
||||
a := int(buffer[1]) + 256*int(buffer[2])
|
||||
ping_reply[0] = buffer[0]
|
||||
ping_reply[1] = buffer[1]
|
||||
ping_reply[2] = buffer[2]
|
||||
ping_reply[3] = buffer[3]
|
||||
ping_reply[4] = buffer[4]
|
||||
ping_reply[5] = buffer[5]
|
||||
ping_reply[6] = buffer[6]
|
||||
|
||||
fmt.Printf("->Command: %d %d PING_REQUEST\n", buffer[0], a)
|
||||
binary.Write(c, binary.LittleEndian, ping_reply)
|
||||
sendPingReply(c, buffer)
|
||||
|
||||
// text message received
|
||||
case RAW_TEXT:
|
||||
@ -404,7 +394,7 @@ func main() {
|
||||
inventar = append(inventar, *v1)
|
||||
}
|
||||
|
||||
binary.Write(c, binary.LittleEndian, sendLogin(configuration.Credential.User, configuration.Credential.Password))
|
||||
sendLogin(c, configuration.Credential.User, configuration.Credential.Password)
|
||||
|
||||
sec := time.Now().Unix()
|
||||
|
||||
|
||||
22
sending.go
22
sending.go
@ -2,13 +2,11 @@ package main
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"net"
|
||||
)
|
||||
|
||||
/* login to El */
|
||||
func sendLogin(user string, password string) []byte {
|
||||
func sendLogin(c net.Conn, user string, password string) {
|
||||
s := user + " " + password
|
||||
lungime := len(s) + 3
|
||||
b := make([]byte, lungime+2)
|
||||
@ -17,7 +15,20 @@ func sendLogin(user string, password string) []byte {
|
||||
b[2] = byte(lungime / 256)
|
||||
copy(b[3:], s)
|
||||
b[lungime+1] = 0
|
||||
return b
|
||||
binary.Write(c, binary.LittleEndian, b)
|
||||
}
|
||||
|
||||
/* Send back to server what we received */
|
||||
func sendPingReply(c net.Conn, b []byte) {
|
||||
ping_reply := make([]byte, 7)
|
||||
ping_reply[0] = b[0]
|
||||
ping_reply[1] = b[1]
|
||||
ping_reply[2] = b[2]
|
||||
ping_reply[3] = b[3]
|
||||
ping_reply[4] = b[4]
|
||||
ping_reply[5] = b[5]
|
||||
ping_reply[6] = b[6]
|
||||
binary.Write(c, binary.LittleEndian, ping_reply)
|
||||
}
|
||||
|
||||
func sendMessage(c net.Conn, user string, mesaj string) {
|
||||
@ -56,7 +67,8 @@ func sendTrade(c net.Conn, actor int) {
|
||||
msg[4] = byte(actor / 256)
|
||||
msg[5] = 0
|
||||
msg[6] = 0
|
||||
fmt.Printf("Send trade hex dump: %s\n", hex.Dump(msg))
|
||||
// @TODO@ - Add proper debug statement
|
||||
// fmt.Printf("Send trade hex dump: %s\n", hex.Dump(msg))
|
||||
binary.Write(c, binary.LittleEndian, msg)
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user