Search Results

Search found 11 results on 1 pages for 'alp'.

Page 1/1 | 1 

  • python Socket.IO client for sending broadcast messages to TornadIO2 server

    - by Alp
    I am building a realtime web application. I want to be able to send broadcast messages from the server-side implementation of my python application. Here is the setup: socketio.js on the client-side TornadIO2 server as Socket.IO server python on the server-side (Django framework) I can succesfully send socket.io messages from the client to the server. The server handles these and can send a response. In the following i will describe how i did that. Current Setup and Code First, we need to define a Connection which handles socket.io events: class BaseConnection(tornadio2.SocketConnection): def on_message(self, message): pass # will be run if client uses socket.emit('connect', username) @event def connect(self, username): # send answer to client which will be handled by socket.on('log', function) self.emit('log', 'hello ' + username) Starting the server is done by a Django management custom method: class Command(BaseCommand): args = '' help = 'Starts the TornadIO2 server for handling socket.io connections' def handle(self, *args, **kwargs): autoreload.main(self.run, args, kwargs) def run(self, *args, **kwargs): port = settings.SOCKETIO_PORT router = tornadio2.TornadioRouter(BaseConnection) application = tornado.web.Application( router.urls, socket_io_port = port ) print 'Starting socket.io server on port %s' % port server = SocketServer(application) Very well, the server runs now. Let's add the client code: <script type="text/javascript"> var sio = io.connect('localhost:9000'); sio.on('connect', function(data) { console.log('connected'); sio.emit('connect', '{{ user.username }}'); }); sio.on('log', function(data) { console.log("log: " + data); }); </script> Obviously, {{ user.username }} will be replaced by the username of the currently logged in user, in this example the username is "alp". Now, every time the page gets refreshed, the console output is: connected log: hello alp Therefore, invoking messages and sending responses works. But now comes the tricky part. Problems The response "hello alp" is sent only to the invoker of the socket.io message. I want to broadcast a message to all connected clients, so that they can be informed in realtime if a new user joins the party (for example in a chat application). So, here are my questions: How can i send a broadcast message to all connected clients? How can i send a broadcast message to multiple connected clients that are subscribed on a specific channel? How can i send a broadcast message anywhere in my python code (outside of the BaseConnection class)? Would this require some sort of Socket.IO client for python or is this builtin with TornadIO2? All these broadcasts should be done in a reliable way, so i guess websockets are the best choice. But i am open to all good solutions.

    Read the article

  • Middle Mouse Button does not work in XFCE / Arch Linux

    - by Alp
    I have the XFCE desktop manager installed on my Arch Linux system. With E17 (Enlightenment desktop manager) i had no problems with my mouse: all buttons worked correctly out of the box. But in XFCE my middle mouse button does not fire an event at all (no output with xev). Evdev seems to identify my mouse correctly (Razer Deathadder) because it echoes its name in the xorg logs. I have no idea what could cause this and how to debug the problem. I start both e17 and xfce with startx. Here is my ~/.xinitrc: exec startxfce4 --with-ck-launch #exec enlightenment-start

    Read the article

  • Custom ViewModel with MVC 2 Strongly Typed HTML Helpers return null object on Create ?

    - by Barbaros Alp
    Hi, I am having a trouble while trying to create an entity with a custom view modeled create form. Below is my custom view model for Category Creation form. public class CategoryFormViewModel { public CategoryFormViewModel(Category category, string actionTitle) { Category = category; ActionTitle = actionTitle; } public Category Category { get; private set; } public string ActionTitle { get; private set; } } and this is my user control where the UI is <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CategoryFormViewModel>" %> <h2> <span><%= Html.Encode(Model.ActionTitle) %></span> </h2> <%=Html.ValidationSummary() %> <% using (Html.BeginForm()) {%> <p> <span class="bold block">Baslik:</span> <%=Html.TextBoxFor(model => Model.Category.Title, new { @class = "width80 txt-base" })%> </p> <p> <span class="bold block">Sira Numarasi:</span> <%=Html.TextBoxFor(model => Model.Category.OrderNo, new { @class = "width10 txt-base" })%> </p> <p> <input type="submit" class="btn-admin cursorPointer" value="Save" /> </p> <% } %> When i click on save button, it doesnt bind the category for me because of i am using custom view model and strongly typed html helpers like that <%=Html.TextBoxFor(model => Model.Category.OrderNo) %> How can i fix this ? Thanks in advance

    Read the article

  • I can't access Page.RouteData or Response.RedirectPermanent in web forms upgraded from 3.5 to 4.0 ?

    - by Barbaros Alp
    Hi, I have upgraded my web application from 3.5 to 4.0 to get benefits of the new features of ASP.NET 4.0. When i try to get Route Data Values; Page.RouteData.Values["customerId"] with this code i couldn't reach the RouteData.Values collection the Page class doesnt contain a member called routedata. I also have the same issue with Response.RedirectPermanent... What might be the reason ? Thanks in advance

    Read the article

  • Why do i need PUT or DELETE Http Verbs ?

    - by Barbaros Alp
    After the release of MVC 2, i have started to check and play with the new features. But i couldnt understand that why do i need to use PUT or DELETE verbs ? I have searched about it and read some articles but i couldnt get it. What is the main purpose of DELETE and PUT (and do they have any advantages rather than using a GET or POST method) even though i can handle all of the requests with GET and POST...

    Read the article

  • WPF - Adding ContentControl to Custom Canvas

    - by Alp Hancioglu
    I have a custom DrawingCanvas which is inherited from Canvas. When I add a ContentControl to DrawingCanvas with the following code nothing shows up. GraphicsRectangle rect = new GraphicsRectangle(0, 0, 200, 200, 5, Colors.Blue); DrawingContainer host = new DrawingContainer(rect); ContentControl control = new ContentControl(); control.Width = 200; control.Height = 200; DrawingCanvas.SetLeft(control, 100); DrawingCanvas.SetTop(control, 100); control.Style = Application.Current.Resources["DesignerItemStyle"] as Style; control.Content = host; drawingCanvas.Children.Add(control); GraphicsRectangle is a DrawingVisual and the constructor above draws a Rect with (0,0) top left point and length of 200 to the drawingContext of GraphicsRectangle. DrawingContainer is a FrameworkElement and it has one child, which is rect above, given with constructor. DrawingContainer implements GetVisualChild and VisualChildrenCount override methods. At last, Content property of ContentControl is set to the DrawingContainer to be able to show the DrawingVisual's content. When I add the created ContentControl to a regular Canvas, control is showed correctly. I guess the reason is that DrawingCanvas doesn't implement ArrangeOverride method. It only implements MeasureOverride method. Also DrawingContainer doesn't implement Measure and Arrange override methods. Any ideas?

    Read the article

  • Why is the C# SerializedAttribute is sealed?

    - by ahmet alp balkan
    I was trying to create an attribute that implies [Serializable] but I noticed that this SerializableAttribute class is sealed. In Java it was possible to create an interface (say, MyInterface) that is inherited from Serializable interface and so all the subclasses of MyInterface would also be serializable, even its sub-sub classes would be so. Let's say I am creating an ORM and I want customers to annotate their entity classes as [DatabaseEntity] but in order to make sure that entities are serializable, I also need to ask them to attribute their classes with extra [Serializable] which does not look quite compact and neat. I am wondering why SerializableAttribute class is sealed and why has Inherited=false which implies that subclasses of serializable class will not be serializable unless it is explicitly stated. What motives are behind these design choices?

    Read the article

  • R: NA/NaN/Inf in foreign function call (arg 1)

    - by Ma Changchen
    When i use a package named HydroMe to fit a model, some data groups will return the following errors: Error in qr.default(.swts * attr(rhs, "gradient")) : NA/NaN/Inf in foreign function call (arg 1) Actually,there is no missing value in the data groups. the codes are as followed: library(HydroMe) fortst<-read.csv(file="F:/fortst.csv") van.lis <-nlsList(y~SSvan(x,Thr, Ths, alp, scal)|Sample,data=fortst) datas are as following: Sample x y 1116 0.000001 0.4003 1116 10 0.3402 1116 20 0.3439 1116 30 0.3432 1116 40 0.3426 1116 60 0.3379 1116 90 0.3325 1116 180 0.3212 1116 405 0.3033 1116 810 0.2843 1116 1630 0.2659 1117 0.000001 0.3785 1117 10 0.3173 1117 20 0.3199 1117 30 0.3193 1117 40 0.3179 1117 60 0.313 1117 90 0.308 1117 180 0.2973 1117 405 0.2789 1117 810 0.2608 1117 1630 0.2405 the example data can be downloaded from here.

    Read the article

  • The dictionary need to add every word in SpellingMistakes and the line number but it only adds the l

    - by Will Boomsight
    modules import sys import string Importing and reading the files form the Command Prompt Document = open(sys.argv[1],"r") Document = open('Wc.txt', 'r') Document = Document.read().lower() Dictionary = open(sys.argv[2],"r") Dictionary = open('Dict.txt', 'r') Dictionary = Dictionary.read() def Format(Infile): for ch in string.punctuation: Infile = Infile.replace(ch, "") for no in string.digits: Infile = Infile.replace(no, " ") Infile = Infile.lower() return(Infile) def Corrections(Infile, DictWords): Misspelled = set([]) Infile = Infile.split() DictWords = DictWords.splitlines() for word in Infile: if word not in DictWords: Misspelled.add(word) Misspelled = sorted(Misspelled) return (Misspelled) def Linecheck(Infile,ErrorWords): Infile = Infile.split() lineno = 0 Noset = list() for line in Infile: lineno += 1 line = line.split() for word in line: if word == ErrorWords: Noset.append(lineno) sorted(Noset) return(Noset) def addkey(error,linenum): Nodict = {} for line in linenum: Nodict.setdefault(error,[]).append(linenum) return Nodict FormatDoc = Format(Document) SpellingMistakes = Corrections(FormatDoc,Dictionary) alp = str(SpellingMistakes) for word in SpellingMistakes: nSet = str(Linecheck(FormatDoc,word)) nSet = nSet.split() linelist = addkey(word, nSet) print(linelist) # # for word in Nodict.keys(): # Nodict[word].append(line) Prints each incorrect word on a new line

    Read the article

1