Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
8203 Visualizzazioni

Hello, I'm creating a proxy server to manage the interface between the pos module and the electronic scale. I receive well the http get request on my server, but I don't understand in wich format I have to answer with the actual weight... Can somebody tell me the correct answer format for this json request?

Here is the request I receive:

/pos/weighting_start?jsonp=jQuery18302055237984620708_1361460794237&id=r360&r=%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22call%22%2C%22params%22%3A%7B%22context%22%3A%7B%7D%7D%2C%22id%22%3A%22r360%22%7D&_=1361460812032

Url = {htp://localhost:6655/pos/weighting_start?jsonp=jQuery18302055237984620708_1361460794237&id=r360&r={"jsonrpc":"2.0","method":"call","params":{"context":{}},"id":"r360"}&_=1361460812032}

For the javascript code, it's the original device.js (..\server\openerp\addons\point_of_sale\static\src\js):

//returns the weight on the scale. 
        // is called at regular interval (up to 10x/sec) between a weighting_start()
        // and a weighting_end()
        weighting_read_kg: function(){
            var self = this;
            if(this.bypass_proxy){
                return this.weight;
            }else{
                this.message('weighting_read_kg',{})
                    .done(function(weight){
                        if(self.weighting && !self.bypass_proxy){
                            self.weight = weight;
                        }
                    });
                return this.weight;
            }
        },

I'm making the server in C#.

I have every data I need but don't know how to format them... Here is the reponse code:

private void HttpWebServer_SendData()
        {
            if (context == null) return;

            string responseString = RxString;
            byte[] buffer = Encoding.UTF8.GetBytes(responseString);
            context.Response.ContentLength64 = buffer.Length;

            context.Response.Headers.Set(HttpResponseHeader.Server, "Serial to http Server");

            System.IO.Stream output = context.Response.OutputStream;
            output.Write(buffer, 0, buffer.Length);
            output.Close();
        }

where RxString is the actual weight, ex: "120.5"

Thank you

Avatar
Abbandona

Can you post your json structure? That way you will get more opportunities to have some answer. Maybe you just have a minor error on the json structure or alike and it will be easier to detect it.

Edit your question and add there the code. Use the Edit option, it's the small pencil under the question, aligned to the right.

Autore

Sorry, I'll do this

Autore

Nobody can give me an example of proxy answer that the POS 7.0 is waiting in the weighting_read_kg loop?

Autore

Here is the JQuery - JSON Exchange I get: Request: {http://localhost:6655/pos/weighting_start?jsonp=jQuery183021106903867513827_1362069234058&id=r360&r={"jsonrpc":"2.0","method":"call","params":{"context":{}},"id":"r360"}&_=1362069249742}

Response: "{\"jsonrpc\": \"2.0\", \"result\": 12.5, \"id\": \"r360\"}"

I still get a script error in the POS frontend.

Post correlati Risposte Visualizzazioni Attività
1
gen 25
5616
1
lug 25
99
2
dic 18
5109
0
giu 17
4355
1
mar 15
4606