Online 3D chat system [W.I.P]

Hey everyone.

I have been doing networking over the past few days and I started making a 3D chat system for a game.

so far you can only enter your name and login to this world where you are a cube with your name on top of it.
you can move around and chat with others.

The client and server networking are both done in python.
I am thinking about making a server in C++ and the client in blender/python for a little online game.

Attachments


would anyone want the .blend file to test it out with me?

ok, ill test it.
when?

we could do it right now if thats okay with you.

just download the file attached.

BTW am using the latest blender 2.56

Attachments

client.blend (395 KB)

sorry heres the file because I forgot to pack the image into it.

Attachments

client.blend (430 KB)

I just uploaded a video of it in progress.

The video is a bit laggy because my pc is slow and also because the server and two clients running at the same time.

This is the client so far if anyone wants to try it out right now or to have a look at the code.

Attachments

client.blend (427 KB)

Send me a Pm with your msn too

a very good demonstration, but it lacks the server for download, only 50% are client download posted

but anyway good job

Could it be adapted for 2.49?

Matthew.

I honestly do not know, because I use Blender 2.56.2
2:49 Blender is weak and with fewer functions so changed it so that the new Blender launched

Yes I have made a client server before in blender 2.49b. check my previous thread.

I will also include the server if anyone wants to try them. don’t forget to look for the code and change the IP address to whatever is yours.

from socket import *
from pickle import *
import select

sock = socket(AF_INET, SOCK_STREAM)

sock.bind(("192.168.1.3", 1993))
sock.setblocking(0)
sock.listen(5)

ID = 0
updatelist = []
newusers = []
users = []
chat = []
clients = []
deadclients = []
while True:
    try:
        client, addr = sock.accept()
        print("connection from...", addr)
        read, write, error = select.select([client],[],[],1)
        if(len(read) > 0):
            for x in read:
                try:
                    username = x.recv(1024)
                    username = loads(username)
                    user = [ID, username, client, addr, 0.1,0.1]
                    users.append(user)
                    updatelist.append(user)
                    newusers.append(user)
                    clients.append(client)
                    ID = ID + 1
                except:
                    client.close()
    except:
        pass

    if(len(clients) > 0):
        read, write, error = select.select(clients, [],clients,1)
        if len(error) > 0:
            for x in error:
                x.close()
                for y in users:
                    if x == y[2]:
                        users.remove(y)
        if (len(read) > 0):
            for x in read:
                try:
                    data = x.recv(1024)
                    if(not data):
                        for y in users:
                            if y[2] == x:
                                x.close()
                                users.remove(y)
                                clients.remove(x)
                                data = [-1,y[0]]
                                data = dumps(data)
                                for u in users:
                                    try:
                                        u[2].send(data)
                                    except:
                                        print("couldn't send killed connections")
                                print("removed client")
                                break
                    data = loads(data)
                    if(data[0] == 1):
                        c = [data[1],data[2],data[3]]
                        chat.append(c)
                    if(data[0] == 2):
                        if(data[3] == 1):
                            for it in users:
                                if x == it[2]:
                                    it[5] = it[5] + 0.25
                                    updatelist.append(it)
                                    break
                        elif(data[3] == 2):
                            for it in users:
                                if x == it[2]:
                                    it[4] = it[4] - 0.25
                                    updatelist.append(it)
                                    break
                        elif(data[3] == 3):
                            for it in users:
                                if x == it[2]:
                                    it[5] = it[5] - 0.25
                                    updatelist.append(it)
                                    break
                        elif(data[3] == 4):
                            for it in users:
                                if x == it[2]:
                                    it[4] = it[4] + 0.25
                                    updatelist.append(it)
                                    break
                            
                except:
                    pass
    if (len(clients) > 0):
        read, write, error = select.select([],clients,clients,1)
        if len(error) > 0:
            for x in error:
                x.close()
                for y in users:
                    if x == y[2]:
                        users.remove(y)
        if(len(write)>0):
            for x in clients:
                for iter in newusers:
                    if x == iter[2]:
                        try:
                            x.send(dumps(str(iter[0])))
                            for u in users:
                                d = [2,u[0],u[1],u[4],u[5]]
                                d = dumps(d)
                                iter[2].send(d)
                                print("data send")
                            newusers.remove(iter)
                            #break
                        except:
                            x.close()
                            for y in users:
                                if x == y[2]:
                                    users.remove(y)
                                    break
                            clients.remove(x)
                            print("closed connection because ID not send")
                for iter in updatelist:
                    update = [2,iter[0],iter[1],iter[4],iter[5]]
                    try:
                        x.send(dumps(update))
                    except:
                        x.close()
                        for y in users:
                            if x == y[2]:
                                users.remove(y)
                                break
                        clients.remove(x)
                        print("closed connection because failed to update")
                for iter in chat:
                    mess = [1,iter[0],iter[1],iter[2]]
                    try:
                        x.send(dumps(mess))
                    except:
                        x.close()
                        for y in users:
                            if x == y[2]:
                                users.remove(y)
                                break
                        clients.remove(x)
                        print("closed connection because faailed to chat")
            updatelist = []
            chat = []
#    if len(users) > 0:
#        for x in users:
#            print(x)
sock.close()

I know that I could improve the server to be faster and also the client but I did this as a short project.