View unanswered posts | View active topics

Reply to topic  [ 3 posts ] 

Joined: Wed Jun 08, 2011 8:59 am
Posts: 4
Post Need help writing a Channel Hook
Dear Sir,
I have some question related to Awasu API interface


1] If I require Http responce in my Application which is written in C# than
how will i get it ,If possible please pprovide me some example code for
that.

2] I want to create C# base channel hook by that My application directly et
new feed data so please guide me on that and if possible provide me example
code for that.


3] How channel hook will inform or notify to my application written in c#
regarding new feed available on subscribed channel.


Thu Jun 09, 2011 6:30 am
Profile
Site Admin
User avatar

Joined: Fri Feb 07, 2003 8:48 am
Posts: 2897
Location: Melbourne, Australia
Post Re: Need help writing a Channel Hook
virla wrote:
1] If I require Http responce in my Application which is written in C# than
how will i get it ,If possible please pprovide me some example code for
that.

When you send a HTTP request, you will get an HTTP response. How to read this response is C#-specific and nothing to do with Awasu. We're not C# people here so you probably need to get help elsewhere for this one.

virla wrote:
2] I want to create C# base channel hook by that My application directly et
new feed data so please guide me on that and if possible provide me example
code for that.

The LogChannelActivity sample hook I mentioned elsewhere contains everything you need to write your own hook. Unfortunately, we don't have any samples in C#.

virla wrote:
3] How channel hook will inform or notify to my application written in c#
regarding new feed available on subscribed channel.

When your channel hook script gets called, it will be passed all the details of the newly-received content. How your script passes it on to your main application is entirely up to you.


Fri Jun 10, 2011 10:10 am
Profile WWW
User avatar

Joined: Mon Sep 08, 2008 3:16 pm
Posts: 226
Location: Elk Grove, California
Post Re: Need help writing a Channel Hook
virla wrote:
1] If I require Http responce in my Application which is written in C# than how will i get it ,If possible please pprovide me some example code for that.

To make HTTP requests (and receive HTTP responses) in C# you can use the System.Net.WebClient Class.
This page contains examples: http://msdn.microsoft.com/en-us/library/system.net.webclient(v=vs.80).aspx

virla wrote:
2] I want to create C# base channel hook by that My application directly et new feed data so please guide me on that and if possible provide me example code for that.

This is a bare-bones example that really doesn't do anything useful, It's using the ini-parser library to parse the INI file that Awasu provides. It's coded to be called from Awasu "ConsolidatedNewFeedItems" event, so it's looking for INI file sections that start with "NewFeedItem"
Code:
using IniParser;
using System;
using System.Text;

namespace AwasuExtensions
{
    class AwasuChannelHook
    {
        enum ExitCode : int
        {
            Success = 0,
            MissingArguments = 1,
            InvalidIniFile = 2,
            UnknownError = 10
        };
       
        static void Main(string[] args)
        {
            // Exit with error message if an INI file path wasn't passed
            if (args.Length == 0)
            {
                System.Console.WriteLine("Error: INI file must be passed as first argument.");
                System.Environment.Exit((int)ExitCode.MissingArguments);
            }

            FileIniDataParser parser = new FileIniDataParser();
            IniData data;

            try
            {
                data = parser.LoadFile(args[0]);

                //Iterate through all the sections
                foreach (SectionData section in data.Sections)
                {
                    if (section.SectionName.StartsWith("NewFeedItem"))
                    {
                        // Do something interesting here.
                        // These three lines are not very interesting.
                        Console.WriteLine(section.SectionName);
                        Console.WriteLine("\t" + section.Keys["ItemTitle"]);
                        Console.WriteLine("\t" + section.Keys["PlainTextDescription"]);
                    }
                }
            }
            catch (Exception)
            {
                System.Console.WriteLine("Error: Invalid INI file or path.");
                System.Environment.Exit((int)ExitCode.InvalidIniFile);
            }
        }
    }
}

virla wrote:
3] How channel hook will inform or notify to my application written in c# regarding new feed available on subscribed channel.

That's something only you can answer.
What is your application? A GUI-based EXE? A console-based EXE? A web application?

A Channel hook can call virtually any other process: SOAP, REST, COM, etc.
How is your application callable?

What are you trying to accomplish?


Fri Jun 10, 2011 8:02 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online
Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron