Esempio n. 1
0
/*
Connect to xmms server, both tcp or unix socket are works.

    x = NewXmms2Client("test")
    x.Connect("unix://somewhere")
    x.Connect("tcp://somewhere")

*/
func (x *Xmms2Client) Connect(url string) error {
	cUrl := C.CString(url)
	defer C.free(unsafe.Pointer(cUrl))
	r := C.xmmsc_connect(x.connection, cUrl)
	if r == 0 {
		errInfo := C.GoString(C.xmmsc_get_last_error(x.connection))
		return errors.New(fmt.Sprintf("Connection failed: %s", errInfo))
	}
	return nil
}
Esempio n. 2
0
func (x *Xmms2Client) checkError(hintString string) error {
	if int(C.macro_xmmsc_result_iserror(x.result)) != 0 {
		errorBuff := C.xmmsc_get_last_error(x.connection)
		defer C.free(unsafe.Pointer(errorBuff))
		return errors.New(fmt.Sprintf(
			hintString, C.GoString(errorBuff),
		))
	}
	return nil
}
Esempio n. 3
0
func (c *Connector) GetLastError() error {
	cErrInfo := C.xmmsc_get_last_error(c.connection)
	defer C.free(unsafe.Pointer(cErrInfo))
	return fmt.Errorf(C.GoString(cErrInfo))
}