dispatch

how to dispatch network requests to the (geographically) closest server

I'm a Java coder and not very familiar with how networks work (other than basic UDP/TCP connections) Say I have servers running on machines in the US, Asia, Latin America and Europe. When a user requests a service, I want their request to go to the server closest to them. Is it possible for me to have one address: mycompany.com, and s...

For Objective-C ... Pointer to method

I want to setup a Method dispatch table and I am wondering if it is possible to create pointer to a method in Objective-C (like pointer to function in C). I tried to use some obj-c runtime functions to dynamically switch methods but the problem is it will affect all instances. As I am very new to obj-c, an illustrated example would be ...

Designing a generic servlet which handles request dispatching

Hi! I have a design question :) I want to have multiple servlets but I dont want to configure a new servlet with a new name each time and extend the HttpServlet. I was thinking of having a generic servlet which dispatches different parameters to different specific classes that are actually handling the request. Ex: theese two calls w...

method overloading and polymorphism

I'm writing a .NET web application in which administrators can customize the various data entry forms presented to their users. There are about half a dozen different field types that admins can create and customize (i.e. text, numeric, dropdown, file upload). All fields share a set of base attributes/behaviors (is the field required? ...

How to dispatch url with subdomain in Zend PHPUnit Controller test?

I want to test my controller which works on subdomain www.username.domain.com The problem is when I dispatch in ControllerTestCase it throws Zend_Controller_Dispatcher_Exception routes.php: $userRouter = new Zend_Controller_Router_Route_Hostname(':user.domain.com')); $router->addRoute('user', $userRouter->chain(new Zend_Controller_...

jQuery dispatch event from a plugin for multiple listeners

I'm looking for a way to dispatch an event from my jQuery plugin so that it can have multiple listeners for that event. I have the plugin setup so that it returns a reference to itself so that I can add listeners later via public methods. The only examples I've seen so far have a single event handler, e.g.: $.fn.foo = function( options...

Problem with Scala Dispatch Databinder library

I am using the Dispatch Databinder library for Http in Scala. I have this method. def testCheckPage(url:String):String = { try { var http = new Http var request = new Request(url) val req_with_agent = request <:< Map("User-Agent" -> "Mozilla/4.0") val responseBody = Http (req_...

Polymorphism in AspectJ

I am trying to decide which is the better way to dispatch on a type in AspectJ. Suppose I am performing a computation on a tree with three kinds of nodes. I could then write a simple Java method: private void computation(TreeNode node) { if (node instanceof Node0) { // Do stuff. } else if (node instanceof Node0) { ...

Flex Event.ID3 dispatches twice

Hi, Why does this code mySound.addEventListener(Event.ID3, myID3Handler); cause the myID3Handler to run twice ?! I also notice that values provided to the handler are not the same, actually the second being the correct one. Thanks ...

Dynamic method dispatch based on value of variable

Hi there, Long switch statments are often frowned upon. The solution is to use polymorphism. However what if the thing I'm switching on is not a type code? What I would like to do is replace the switch statement with something like this... public void HandleString(string s = "Hello") { ... } public void HandleString(string s = "Goodb...

How can I create a type based lookup table in order to implement multiple-dispatch in C++?

I'm attempting to make a messaging system in which any class derived from "Messageable" can receive messages based on how the function handleMessage() is overloaded. For example: class Messageable { public: void takeMessage(Message& message) { this->dispatchMessage(message); } prot...

What is a simple way to receive SNMP traps in Scala?

I'd love it if there is an awesome native Scala library for SNMP like there is Dispatch for HTTP but I can't find one. Is there one? Baring that, should I use a Java library like SNMP4J? What I want to do is so simple that it almost seems like overkill: I just want to listen on a given port for SNMP messages (which will always be in the ...

How does an OS or a systems program wait for user input?

I come from the world of web programming and usually the server sets a superglobal variable through the specified method (get, post, etc) that makes available the data a user inputs into a field. Another way is to use AJAX to register a callback method to an event that the AJAX XMLhttpRequest object will initiate once notified by the bro...

Magento dispatching outside application

Hi all, I'm trying to figure out how exactly Magento's dispatching system works. I want to dispatch a certain part of the layout (e.g. the body) from outside the application directory. What i have so far; <?php $app = Mage::app(); $myRequestUri = '/checkout/cart'; $front = $app->getFrontController(); $request = ...

AS3 - Event listener that only fires once

I'm looking for a way to add an EventListener which will automatically removes itself after the first time it fires, but I can't figure a way of doing this the way I want to. I found this function (here) : public class EventUtil { public static function addOnceEventListener(dispatcher:IEventDispatcher,eventType:String,listener:Func...

http(/* argument here */) How is this Object (Http) being used without an explicit or implicit method?

In the example for coding with Json using Databinder Dispatch Nathan uses an Object (Http) without a method, shown here: import dispatch._ import Http._ Http("http://www.fox.com/dollhouse/" >>> System.out ) How is he doing this? Thank you for all of the answers unfortunatly I was not specific enough... It looks like it is simply pas...

Is is possible to do an end-run around generics covariance in C# < 4 in this hypothetical situation?

Suppose I have a small inheritance hierarchy of Animals: public interface IAnimal { string Speak(); } public class Animal : IAnimal { public Animal() {} public string Speak() { return "[Animal] Growl!"; } } public class Ape : IAnimal { public string Speak() { return "[Ape] Rawrrrrrrr!"; } } pub...

How do I dispatch to a method based on a parameter's runtime type in C# < 4?

I have an object o which guaranteed at runtime to be one of three types A, B, or C, all of which implement a common interface I. I can control I, but not A, B, or C. (Thus I could use an empty marker interface, or somehow take advantage of the similarities in the types by using the interface, but I can't add new methods or change existi...

c# Generic overloaded method dispatching ambiguous

Hello, I just hit a situation where a method dispatch was ambiguous and wondered if anyone could explain on what basis the compiler (.NET 4.0.30319) chooses what overload to call interface IfaceA { } interface IfaceB<T> { void Add(IfaceA a); T Add(T t); } class ConcreteA : IfaceA { } class abstract BaseClassB<T> : IfaceB<T>...

RuntimeException from Google Analytics for Android "sending message to a handler on a dead thread"

I am using Google Analytics for Android to track events, page views on an Android app. When calling the tracker's dispatch method, I receive a RuntimeException: 07-12 18:02:05.594: WARN/MessageQueue(12823): Handler{44a08620} sending message to a Handler on a dead thread 07-12 18:02:05.594: WARN/MessageQueue(12823): java.lang.RuntimeExce...