Browse Source

fixed a rather odd drawing bug

master
asiekierka 5 years ago
parent
commit
92d997b4cd
3 changed files with 8 additions and 4 deletions
  1. 4
    1
      app.js
  2. 2
    2
      lib/grayboard.js
  3. 2
    1
      room.js

+ 4
- 1
app.js View File

@@ -6,6 +6,8 @@ var express = require('express')
, fs = require("fs")
, _ = require('underscore');

io.set("origins","*asie.pl*:*");

// People would murder for this line. It's really bad.
eval(fs.readFileSync('lib/grayboard-util.js','utf8'));
eval(fs.readFileSync('lib/grayboard-canvas.js','utf8'));
@@ -137,12 +139,13 @@ io.sockets.on('connection', function(socket) {
socket.on('join_room', function(data) {
roomName = Room.getName(data);
socket.join(data);
var room = Room.create(roomName,config.room);
var room = Room.create(roomName, config.room);
var chat = new Chat(room,config.chat);
var user = new User(socket,"");
user.genNickname(room.config.nickname);
room.addUser(user);
room.chat = chat;
console.log(room);
socket.emit('init',room.getInitCmd());
sendChat(socket,null,chat.process('','Welcome to room ' + roomName + '!','server'));
sendChat(socket.broadcast.to(data),null,chat.process("",user.nickname + " has joined the room!","server"));

+ 2
- 2
lib/grayboard.js View File

@@ -85,7 +85,7 @@ function keyHandler(e) {

function changeBrushSize(val) {
pointBrush.size = val;
$('#size_val').text(val+"px");
$('#size_val').text(Math.floor(val)+"px");
}

function checkMenubar() {
@@ -186,7 +186,7 @@ function initMenubar() {
}

function initSockets() {
socket = io.connect(config.socketURL);
socket = io.connect("http://asie.pl:17000");
socket.emit("join_room", "room_" + config.roomName);
socket.on("draw_command", function(data) {
try {

+ 2
- 1
room.js View File

@@ -81,7 +81,7 @@ Room.prototype.addUser = function(user) { user.room = this; this.users[user.id]
Room.prototype.getUser = function(id) { return this.users[id]; }
Room.prototype.removeUser = function(id) { delete this.users[id]; }
Room.findUserRoom = function(id) {
return _.find(Room.rooms,function(room) { return _.isObject(room.getUser(id)); });
return _.find(_.values(Room.rooms),function(room) { return _.isObject(room.getUser(id)); });
}
Room.findUserRoomName = function(id) {
var r = Room.findUserRoom(id);
@@ -126,6 +126,7 @@ Room.prototype.autoBackup = function() {
this.savePNG(this.getPath() + 'canvas.png');
setTimeout(function(){ room.autoBackup(true); }, this.config.autoBackupTime*1000);
}

Room.prototype.loadBackup = function() { this.loadPNG(this.getPath() + 'canvas.png'); }

Room.prototype.loadPNG = function(path) {

Loading…
Cancel
Save