Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Networked Chat experiment

Hey all,
I am trying to build an experiment for simple chat between 2 participants.
One can be the server and other can be the client. I found some samples for OpenSesame 2 but couldn`t find enough data for version 3.2.

Are there any other person who made a similar experiment?
Regards

Comments

  • edited September 2018
    Hi,

    Creating an experiment like that is possible, but how easy it is depends on the details. What *exactly* do you want to do? How should participants interact? And does the experiment consist only of chatting, or is this embedded in other tasks?

    Cheers!
    Sebastiaan
  • Hi Sebastiaan,
    Thanks for the reply, actually it will be part of a larger experiment and connecting two users from separate computers will be part of the task.
    Two users, will try to complete tasks by cooperating with each other. They will be shown different inputs (images, videos or texts).
    They will communicate with each other by sending messages and try to find the answer.

    Is it a bit more clear? I can give more details.
    Regards,
    NB

  • Hi Newbee,

    This sounds like a fairly complicated experiment. Doable, but not trivial at all. Given that you don't seem very experienced in coding, I doubt that you'll be able to implement this, not without a large amount of help (more than you'll likely get on the forum). I may be wrong, but that's the feeling I'm getting.

    So how experienced are you, and do you think you'll be able to manage an experiment that will require a considerable amount of Python coding?

    Cheers,
    Sebastiaan

  • Hello Sebastiaan,
    I am not very experienced on coding, but I found some walkaround and simplified the experiment.
    A separate application will be used for chat and Opensesame will get input from only one user, which makes things a lot easier. I will work on it and ask for support for any obstacles I met.
    Regards,
    NB

  • Hello again Sebastiaan,
    For last couple of days, I tried again to make this experiment work with client and server.
    Now, server and client can make a connection, but they continuously send messages.
    What I want is, when server sends a specific message, client to show screen1 and if server sends another value show screen2.
    This way I try to change screens on client side with feedbacks from the server.
    Attached you can find the simplified experiment, I can not go further than the inline script, because it crashes when I started it.
    Do you have any idea to make it as simple as possible?
    I think establishing the connection and following the steps in the experiment and sending messages when user submit response to the questions which will trigger actions in client side will be what I need. But I couldn`t do it.

  • edited October 2018

    Hello again,
    I made some more changes and now both instances can make the connection but I want the message to be sent to change based on an internal variable (a form input). If this value (var1_1) equals to 33, it should send 30 and if it is some other value it should send 20. But when I run the application I get an error, which is shown below.
    And also, even the input is correct, client always receives 20.

    **Server Script:**
    HOST = ''
    PORT = 8000
    
    
    def task5():
        print ('task 5')
    
    s = socket(AF_INET, SOCK_STREAM)
    s.bind((HOST, PORT))
    s.listen(1)
    conn, addr = s.accept()
    print 'Connected by', addr
    
    var1_1 = "" 
    result = str(var1_1)
    if result == '33':
        var = '30'
    else:
        var = '20'
    
    
    while True:
        data = conn.recv(1024)
        print "Received ", repr(data)
        reply = var
        # print (str(data))
        if str(data) == '50':
            task5()
            conn.sendall(reply)
        elif data == '100':
            conn.close()
            conn.sendall('quit')
            break
        else:
            break
            try:
                conn.sendall('quit')
            except:
                print ('client exited')
    
    conn.close()
    
    **Client Script:**
    from socket import *
    
    HOST = 'localhost'
    PORT = 8000
    s = socket(AF_INET, SOCK_STREAM)
    s.connect((HOST, PORT))
    
    
    def task1():
        print("task one")
        return 'server did task 1'
    
    
    def task2():
        print("task two")
        return 'server did task 2'
    
    var3 =''
    def task3():
        print("task three")
        var3 = '880'
        print(var3)
        return 'server did task 3'
    
    var = '50'
    while True:
        message = var
        s.send(message)
        print "Awaiting reply"
        reply = s.recv(1024)
        print "Received ", repr(reply)
        # print(repr(reply))
        if reply == '10':
            task1()
            break
        elif reply == '20':
            task2()
            break
        elif reply == '30':
            task3()
            break
        elif reply == 'quit':
            break
    s.close()
    
    
    **Error message:**
    Unexpected error
    
    item-stack: experiment[run].Experiment_1[run].Task_Sequence[run]
    exception type: AttributeError
    exception message: 'str' object has no attribute 'var1_1'
    time: Wed Oct 10 09:01:05 2018
    
    Traceback:
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libqtopensesame\misc\process.py", line 157, in run
        exp.run()
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\experiment.py", line 456, in run
        self.items.execute(self.var.start)
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 103, in execute
        self.run(name)
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 122, in run
        self[name].run()
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\sequence.py", line 51, in run
        self.experiment.items.run(_item)
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 122, in run
        self[name].run()
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\sequence.py", line 51, in run
        self.experiment.items.run(_item)
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 122, in run
        self[name].run()
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\sequence.py", line 50, in run
        if self.python_workspace._eval(cond):
      File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\base_python_workspace.py", line 141, in _eval
        return eval(bytecode, self._globals)
      File "<conditional statement>", line 1, in <module>
    AttributeError: 'str' object has no attribute 'var1_1'
    
  • Hi,

    I haven't look at your experiment, so I can't tell you whether you are on the right track, but the specific problem here is that you are overwriting opensesame's builtin var object. It is needed for the experiment to run properly, so it is really a bad idea to do stuff like that; var = '30'. So, simply use different variable names and you should be fine.

    Good luck,

    Eduard

    Buy Me A Coffee

  • Thanks Eduard,
    Seems like it was one of the main problems, now I changed the name to var_sent instead of var.
    and now it can correctly send the message and close the connection.

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games