Beispiel #1
0
// Convenience method for writing responses.
func (this *ErisDbWsService) writeResponse(id string, result interface{}, session *server.WSSession) {
	response := rpc.NewRPCResponse(id, result)
	bts, err := this.codec.EncodeBytes(response)
	fmt.Printf("Response: %v\n", response)
	if err != nil {
		this.writeError("Internal error: "+err.Error(), id, rpc.INTERNAL_ERROR, session)
		return
	}
	session.Write(bts)
}
Beispiel #2
0
// Helper for writing responses.
func (this *ErisDbJsonService) writeResponse(id string, result interface{}, w http.ResponseWriter) {
	fmt.Printf("Result: %v\n", result)
	response := rpc.NewRPCResponse(id, result)
	err := this.codec.Encode(response, w)
	fmt.Printf("Response: %v\n", response)
	if err != nil {
		this.writeError("Internal error: "+err.Error(), id, rpc.INTERNAL_ERROR, w)
		return
	}
	w.WriteHeader(200)
}
Beispiel #3
0
func (this *ScumSocketService) Process(data []byte, session *server.WSSession) {
	resp := rpc.NewRPCResponse("1", "Scumbag")
	bts, _ := json.Marshal(resp)
	session.Write(bts)
}