Create custom queue - c

I've been looking into making a new queue strategy for my asterisk installation, my first project is to join the features of leastrecent and roundrobin in one queue.
I've found a lot of 3rd party callcenter solutions, but haven't been able to determine if any of them uses other strategies than the standards.
So far my thought is that i have to create my own module that adds the functionality. The documentation on creating modules is scarce, besides a well written guide by Russel Bryant.
Is it possible to make some sort of an extention to an existing module, or would i have to replace et completely?
Is there documentation of any sort about creating your own queue strategy ?
i'm running asterisk 11

Sure you can change queue.
Read apps/app_queue.c and extend it as needed. If you have enought skill to extend and TEST queue(multithreaded app), then have be no any issues read app_queue.c
Other solution is use AMI with AsyncAGI call.
http://www.moythreads.com/wordpress/2007/12/24/asterisk-asynchronous-agi/
PS. if you have question like that it is highly not recommended create callcenter. Read more books about asterisk and hire hi-skilled expert to help you. Otherwise very likly CC will not work ok under load.

Related

Implementing a protocol version in my code

I am writing an application which will be used for event sending. As it stands right now the application is done, however in the future there will be additions to the application. Those additions will be new versions. My question is how to actually implement those version. Sure I can go for "if version == xx" but doing that in every method, in constructors, just does not seem as the exact solution, that's why I am asking for help from people with experience in implementing those versions. Thanks!
The problem you are facing can be handled with implementing forward compatibility. Unfortunately, I cannot give you any practical advice without knowing anything about your protocol. There are some general steps you could follow, though:
Only change the protocol if you really have to.
Ensure you do not break backward compatibility.
Force the user to update the application when update the protocol. This ensures there is only one valid version at a time.
If you have to support multiple versions of the protocol you could implement some kind of converter. But this might not work in every case.
I'll deal the problem with Interfaces and Factory pattern.
For example:
Create an Interface with all the methods.
Create differents implementations for each version.
Use Factory to get the proper implementation

Api sdk or database for simulating a turing test?

I'm trying to provide a chat like environment game for kids to detect if the person speaking to them is human or not (similar to what Eugene did).
I'm looking for an SDK or api that would provide me with replies for sentences (either with context of the entire conversation or without). An alternative would be a an entire database of sentences that I'll be able to search for myself and implement my own logic.
Another option is to integrate some kind of open source solution if possible.
Does anyone know of such a service \ solution can could point me to the correct direction?
If you want some database of discusions then try to found some Corpus of dialogs this is the first one which i found. It is the corpus of movie dialogs:
http://www.mpi-sws.org/~cristian/Cornell_Movie-Dialogs_Corpus.html
And if you want some chat-bot to use in your program than is probably easiest way to use some public available api of one. There is again something which could work for you:
http://blog.program-o.com/chatbot-api/
Good Luck

Is there an automated way to document Nancy services?

Is there any way to auto-generate Swagger documentation (or similar) for a Nancy service?
I found Nancy.Swagger, but there's no information on how to use it and the demo application doesn't seem to demonstrate generating documentation (if it does, it's not obvious).
Any help would be appreciated. Thanks!
In my current project I've been looking a lot into this problem. I used both nancy.swagger and nancy.swagger.attributes.
I quickly discarded Nancy.swagger, because for me personally it doesn't sound right that you have to create a pure documentation class for each nancy module. The attributes solution was a bit "cleaner" - at least codebase and documentation were in one place. But very fast this became unmaintainable. Module code is unreadable because of many attributes. Nothing is generated automatically: you have to put path, all parameters, even http method as an attribute. This is a huge effort duplication. Problems came very fast, a few examples:
I changed POST to PUT in Nancy and forgot to update [Method] attribute.
I added a parameter but not the attribute for it.
I changed parameter from path to query and didn't update the attribute.
It's too easy to forget to update the attributes (let alone documentation module solution), which leads to discrepancies between your documentation and actual code base. Our UI team is in another country and they had some trouble using the APIs because docu just wasn't up-to-date.
My solution? Don't mix code and documentation. Generating docu from code (like Swashbuckle does) IS ok, but actually writing docu in code and try to dublicate the code in docu is NOT. It's not better than writing it in a Word document for your clients.
If you want Swagger docu, just do it the Swagger way.
- Spend some time with Swagger.Editor and really author your API in
YAML. It looks all-text and hard, but once you get used to it, it's
not.
- Spend some time with Swagger.Codegen and adapt it (it already does a fair job for generating Nancy server code and with a few
adjustments to moustache templates it was just what I needed).
- Automate your process: write a couple of batches to generate your modules and models from yaml and copy them to your repository.
Benefits? Quite a few:
-
Your YAML definition is now the single truth of your REST contract.
If somewhere something is defferent, it's wrong.
Nancy server code is auto-generated
Client code-bases are auto-generated (in our case it's android, ios and angular)
So whenever I change something in REST contract, all codebases are regenerated and added to projects in one batch. I just have to tell the teams something was updated. They don't have to look through some documents and search for it. They just have their code regenerated and probably see some compile errors, in case of breaking changes.
Do I still use nancy.swagger(.annotations)?
Yes, I do use it in another project, which has just one endpoint with a couple of methods. They don't change often. It's not worth the effort to set up everything, I have my swagger docu fast up and running. But if your project is big, API is changing, and you have multiple code-bases depending on your API, my advice is to invest some time into a real swagger setup.
I am quoting the author answer here from https://github.com/khellang/Nancy.Swagger/issues/59
The installation should be really simple, just pull down the NuGet package, add metadata modules to describe your routes, and hit /api-docs. That should get you the JSON. If you want to add swagger-ui as well, you have to add that manually right now.
No. Not in an automated. https://github.com/yahehe/Nancy.Swagger needs lots of manually created metadata.
There is a nice article here: http://www.c-sharpcorner.com/article/generating-api-document-in-nancy-using-swagger/
Looks like you still have to add swagger-ui separately.

What is equivalent usage of sendmessage()[WINDOWS] in MAC OS X?

I have a ContextualMenuPlugin and an application. When user clicks the option from context menu i need to send a message to my app. In windows i achieved this using sendmessage() function. But i'm new to MAC OS X. Can any one please help me, by giving some api's or functions which will enlighten this situation?
You have plenty of choices on how to get messages into an application on your Macintosh.
The ways I'm thinking of include Apple Events or sockets or kqueues, but there's other stuff I've never even worked with that might even be more useful & appropriate (such as Distributed Objects). Check out this duplicate and/or related question and maybe you'll see a useful answer in there for you that you can build upon.
B.T.W.: how did you construct your Contextual Menu Plugin? Is it in Carbon or Objective C or is it some codeless plugin or plist or? The answer to that question probably will dictate a lot towards how you will be able to talk from your plugin to your app.
If you want to control just your application you might want to look into AppleScript. Using that solution has the added benefit that your users could also use it to automate things via scripting.

Apache module FORM handling in C

I'm implementing an Apache 2.0.x module in C, to interface with an existing product we have. I need to handle FORM data, most likely using POST but I want to handle the GET case as well.
Nick Kew's Apache Modules book has a section on handling form data. It provides code examples for POST and GET, which return an apr_hash_t of the key+value pairs in the form. parse_form_from_POST marshalls the bucket brigade and flattens it into a buffer, while parse_form_from_GET can simply reference the URL. Both routines rely on a parse_form_from_string routine to walk through each delimited field and extract the information into the hash table.
That would be fine, but it seems like there should be an easier way to do this than adding a couple hundred lines of code to my module. Is there an existing module or routines within apache, apr, or apr-util to extract the field names and associated data from a GET or POST FORM into a structure which C code can more easily access? I cannot find anything relevant, but this seems like a common need for which there should be a solution.
I switched to G-WAN which offers a transparent ANSI C scripts interface for GET and POST forms (and many other goodies like charts, GIF I/O, etc.).
A couple of AJAX examples are available at the GWAN developer page
Hope it helps!
While, on it's surface, this may seem common, cgi-style content handlers in C on apache are pretty rare. Most people just use CGI, FastCGI, or the myriad of frameworks such as mod_perl.
Most of the C apache modules that I've written are targeted at modifying the particular behavior of the web server in specific, targeted ways that are applicable to every request.
If it's at all possible to write your handler outside of an apache module, I would encourage you to pursue that strategy.
I have not yet tried any solution, since I found this SO question as a result of my own frustration with the example in the "Apache Modules" book as well. But here's what I've found, so far. I will update this answer when I have researched more.
Luckily it looks like this is now a solved problem in Apache 2.4 using the ap_parse_form_data funciton.
No idea how well this works compared to your example, but here is a much more concise read_post function.
It is also possible that mod_form could be of value.

Resources