Skip to content
Snippets Groups Projects
Commit eee8e8b6 authored by Abhisha Nirmalathas's avatar Abhisha Nirmalathas
Browse files

checking multiple clients

parent e35f67f1
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <assert.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <fcntl.h> #include <fcntl.h>
...@@ -215,13 +216,13 @@ static bool handle_http_request(int sockfd, User_list* users) ...@@ -215,13 +216,13 @@ static bool handle_http_request(int sockfd, User_list* users)
} }
else if (req->method == GET) else if (req->method == GET)
{ {
printf("matches a / url but url isize is %zu\n\n", strlen(req->url)); // printf("matches a / url but url isize is %zu\n\n", strlen(req->url));
Response* resp = initialise_session(req); // Response* resp = initialise_session(req);
char* resp_string = parse_response(resp); // char* resp_string = parse_response(resp);
printf("COOKIE CREATING RESP %s\n", resp_string); // printf("COOKIE CREATING RESP %s\n", resp_string);
// player_session(buff, sockfd, "1_welcome.html", resp_string); // player_session(buff, sockfd, "1_welcome.html", resp_string);
free(resp_string); // free(resp_string);
free(resp); // free(resp);
get_request(buff,sockfd, "1_welcome.html"); get_request(buff,sockfd, "1_welcome.html");
} }
else else
...@@ -270,7 +271,13 @@ int main(int argc, char * argv[]) ...@@ -270,7 +271,13 @@ int main(int argc, char * argv[])
// if ip parameter is not specified // if ip parameter is not specified
serv_addr.sin_addr.s_addr = inet_addr(argv[1]); serv_addr.sin_addr.s_addr = inet_addr(argv[1]);
serv_addr.sin_port = htons(atoi(argv[2])); serv_addr.sin_port = htons(atoi(argv[2]));
char *user_id = malloc(sizeof(char)*(strlen(argv[1])+strlen(argv[2])));
user_id[0] = '\0';
strcat(user_id,argv[1]);
strcat(user_id,argv[2]);
printf("%s\n\n\\n", user_id);
assert(user_id);
free(user_id);
// bind address to socket // bind address to socket
if (bind(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) if (bind(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0)
{ {
......
No preview for this file type
No preview for this file type
...@@ -6,9 +6,10 @@ ...@@ -6,9 +6,10 @@
#include "user.h" #include "user.h"
User* new_user(){ User* new_user(char* id){
User *user = malloc(sizeof(User*)); User *user = malloc(sizeof(User*));
assert(user); assert(user);
user->id = id;
user->n_capacity = 5; user->n_capacity = 5;
user->n_keywords = 0; user->n_keywords = 0;
user->status = WAIT; user->status = WAIT;
......
...@@ -8,6 +8,7 @@ typedef enum ...@@ -8,6 +8,7 @@ typedef enum
typedef struct User { typedef struct User {
char* name; char* name;
char* id;
char** keywords; char** keywords;
int n_keywords; int n_keywords;
STATUS status; STATUS status;
...@@ -19,7 +20,7 @@ typedef struct User_list{ ...@@ -19,7 +20,7 @@ typedef struct User_list{
User **users; User **users;
}User_list; }User_list;
User* new_user(); User* new_user(char* id);
User_list* initialise_player_list(); User_list* initialise_player_list();
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment