{application, irc,
[{description, "IRC protocol application"},
- {vsn, "6"},
+ {vsn, "7"},
{modules, [irc_util, irc_app, irc_sup, irc_net_sup, irc_conn,
irc_object_sup, irc_amqp_listener, irc_command]},
{registered, [irc_sup, irc_dummy]},
-module(irc_conn).
-behavior(gen_server).
--vsn(2).
+-vsn(3).
-define(RECONNECT_TIME, 30000).
terminate(_Reason, _State) ->
ok.
-code_change(1, {irc_state, Instance, Config, Joined, Socket, Buffer} = State, _Extra) ->
- error_logger:info_msg("Converting from version 1 to version 2.~nOld state is~p~n",
- [State]),
-
- [Supervisor|_] = get('$ancestors'),
- [TableId|_] = [Tab || Tab <- ets:all(), Supervisor == ets:info(Tab, owner)],
- {ok, ObjectSupPid} = irc_net_sup:create_object_sup(Instance, Supervisor, TableId),
-
- NewState = {irc_state, Instance,
- Config,
- Joined,
- Socket,
- Buffer,
- Supervisor,
- TableId,
- ObjectSupPid},
-
- error_logger:info_msg("State transition is done.~nNew state is ~p~n",
- [NewState]),
-
- {_, _, _, _, Channels} = Config,
- lists:foreach(fun (Channel) -> add_amqp_listener(Channel, NewState) end, Channels),
-
- error_logger:info_msg("All done starting new version"),
-
- {ok, NewState};
-
-code_change({down, 1}, State, _Extra) ->
- error_logger:info_msg("Converting version 2 to version 1.~nOld state is ~p~n",
- [State]),
-
- #irc_state{instance = Instance,
- config = Config,
- joined = Joined,
- socket = Socket,
- buffer = Buffer,
- supervisor = Supervisor} = State,
-
- irc_net_sup:remove_object_sup(Supervisor),
-
- NewState = {irc_state, Instance, Config, Joined, Socket, Buffer},
- error_logger:info_msg("New state is ~p~n", [NewState]),
-
- {ok, NewState}.
+code_change(_OldVsn, _State, _Extra) ->
+ {error, unsupported}.
send_command(Command) ->
gen_server:cast(self(), {send_command, Command}).