func (c *Channel) Ack(method string, args interface{}, timeout time.Duration) (string, error) {
	msg := &protocol.Message{
		Type:   protocol.MessageTypeAckRequest,
		AckId:  c.ack.getNextId(),
		Method: method,
	}
	waiter := make(chan string)
	c.ack.addWaiter(msg.AckId, waiter)
	err := send(msg, c, args)
	if err != nil {
		c.ack.removeWaiter(msg.AckId)
	}
	select {
	case result := <-waiter:
		return result, nil
	case <-time.After(timeout):
		c.ack.removeWaiter(msg.AckId)
		return "", ErrorSendTimeout
	}
}
Create ack packet based on given data and send it and receive response
package gosocketio
import (
	"encoding/json"
	"errors"
	"github.com/mcoo/OPQBot/golang-socketio-edit/protocol"
	"log"
	"time"
)
var (
	ErrorSendTimeout     = errors.New("Timeout")
	ErrorSocketOverflood = errors.New("Socket overflood")
)
func send(msg *protocol.Message, c *Channel, args interface{}) error {
	defer func() {
		if r := recover(); r != nil {
			log.Println("socket.io send panic: ", r)
		}
	}()
	if args != nil {
		json, err := json.Marshal(&args)
		if err != nil {
			return err
		}
		msg.Args = string(json)
	}
	command, err := protocol.Encode(msg)
	if err != nil {
		return err
	}
	if len(c.out) == queueBufferSize {
		return ErrorSocketOverflood
	}
	c.out <- command
	return nil
}
func (c *Channel) Emit(method string, args interface{}) error {
	msg := &protocol.Message{
		Type:   protocol.MessageTypeEmit,
		Method: method,
	}
	return send(msg, c, args)
}