-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.txt
59 lines (45 loc) · 1.95 KB
/
test.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#program flow
websocket connection
users logins or registers : user/login/name
new user obj created with his socketID
server obj is notified and adds this user to users array
user sends message : user/send/name/message
#Controller test
the controller should be able to delgate action based on string like url
in: string "class/action/param1/param2"
out :
###problem: how do i send a message with this ?
solutions:
* message is 1 of the params if message has slashes it will be cut into an array
* __go back to json__
* send the message in 2 parts, 1 for the action the other for the message
###problem: whats the best way to pass the db handle between classes ?
solution: pass in the connection object:
[http://ralphschindler.com/2012/03/09/php-constructor-best-practices-and-the-prototype-pattern]
[http://stackoverflow.com/questions/18818511/pass-in-the-connection-object-or-create-it-inside-class-oop]
## Login query
if user exits update session col if not create new user and set session col
## problem: how to pass the user socket handle to the user object
* what command to we need ?
login
logout
getActiveUsers
sendMsg
* integrate the controller into the Server ?
* Observer pattern: when user is logged in update user array in server
## we don't want to create a new object each time a user send an action
## observer
server class is an observer of the user class
k
## why do i need a controller class ?
* less dependency
possible chat actions:
user/login/name
user/send/name/msg
chatApp/getActive users
user1 | user2 | message | timestamp
1 2 hi 23
1 2 what ? 25
2
select * from conversation where (user_one = '2' and user_two = '10') or (user_one = '10' and user_two = '2') order by timestamp
insert into conversation (user_one,user_two,message) values(1,2,'hii ther')