-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #328 from zstenger93/test
Test
- Loading branch information
Showing
22 changed files
with
314 additions
and
455 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,8 @@ backend/authentication/images/* | |
media | ||
node_modules | ||
|
||
backend/qrcode* | ||
|
||
#ssl_keys | ||
*.crt | ||
*.key | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Generated by Django 5.0 on 2024-04-28 03:33 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('game', '0002_remove_gamestats_game_history_remove_gamestats_user_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.DeleteModel( | ||
name='UserChannelName', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,29 @@ | ||
// const websocketUrl = 'ws://40.13.7.8:8000/game/asdfasdf/'; | ||
const websocketUrl = 'wss://10.12.2.4/chat/'; | ||
|
||
const websocketUrl = "wss://10.12.2.2/chat/"; | ||
|
||
// Create a new WebSocket instance | ||
const websocket = new WebSocket(websocketUrl); | ||
|
||
// Event listener for WebSocket connection open | ||
websocket.onopen = function(event) { | ||
console.log('WebSocket connection opened.'); | ||
websocket.onopen = function (event) { | ||
console.log("WebSocket connection opened."); | ||
|
||
// Sending a test message to the server | ||
websocket.send(JSON.stringify({ message: 'Hello from the client!' })); | ||
websocket.send(JSON.stringify({ message: "Hello from the client!" })); | ||
}; | ||
|
||
// Event listener for WebSocket messages received | ||
websocket.onmessage = function(event) { | ||
console.log('Message received from server:', event.data); | ||
websocket.onmessage = function (event) { | ||
console.log("Message received from server:", event.data); | ||
// You can add further processing of the received message here | ||
}; | ||
|
||
// Event listener for WebSocket errors | ||
websocket.onerror = function(error) { | ||
console.error('WebSocket error:', error); | ||
websocket.onerror = function (error) { | ||
console.error("WebSocket error:", error); | ||
}; | ||
|
||
// Event listener for WebSocket connection close | ||
websocket.onclose = function(event) { | ||
console.log('WebSocket connection closed.'); | ||
websocket.onclose = function (event) { | ||
console.log("WebSocket connection closed."); | ||
}; | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +0,0 @@ | ||
from .models import * | ||
from django.shortcuts import render, redirect | ||
from django.contrib.auth.decorators import login_required | ||
from .models import * | ||
from user_api.models import AppUser | ||
from django.shortcuts import get_object_or_404 | ||
from django.http.response import JsonResponse | ||
from django.views.decorators.http import require_GET, require_POST | ||
from django.shortcuts import get_object_or_404 | ||
from django.views.decorators.csrf import csrf_exempt | ||
from .consumers import GameConsumer | ||
|
||
from django.contrib.sessions.models import Session | ||
from django.contrib.auth.models import User | ||
|
||
import string | ||
import random | ||
import json | ||
import logging | ||
from django.http import JsonResponse | ||
from channels.layers import get_channel_layer | ||
from asgiref.sync import async_to_sync | ||
|
||
|
||
def get_user_from_session(session_key): | ||
session = Session.objects.get(session_key=session_key) | ||
user_id = session.get_decoded().get("_auth_user_id") | ||
user = User.objects.get(id=user_id) | ||
return user | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
# Then, instead of print, use logger.info (or logger.debug, logger.warning, etc.) | ||
|
||
|
||
def generate_random_lobby_name(length=10): | ||
# Generate a random string of the given length | ||
lobby_name = "".join( | ||
random.choice(string.ascii_letters + string.digits) for _ in range(length) | ||
) | ||
return lobby_name | ||
|
||
|
||
def my_handler(message): | ||
user_id = message.get("user_id") | ||
room_name = message.get("room_name") | ||
print(f"User {user_id} joined room {room_name}") | ||
|
||
|
||
def end_game(request): | ||
lobby_info = request.GET.get("gameinfo", None) | ||
score_board = lobby_info.split(" ") | ||
winner_score = score_board[0] | ||
user1_id = score_board[1] | ||
user2_id = score_board[3] | ||
loser_score = score_board[4] | ||
logger.info(f"Game ended with score: {score_board}") | ||
user1 = get_object_or_404(AppUser, id=user1_id) | ||
user2 = get_object_or_404(AppUser, id=user2_id) | ||
|
||
logger.info(f"Game ended with score: {score_board}") | ||
|
||
return JsonResponse( | ||
{ | ||
"winner": user1, | ||
"score": winner_score, | ||
|
||
"loser": user2, | ||
"scoree": loser_score, | ||
} | ||
) | ||
|
||
|
||
# id1 score1 id2 score2 | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.